Merge do_prune() with build_fdset(). Probably fixes the invalid filedescriptor error.