How about a call similar to closefrom(), but which takes a list of fds not to close, and
closes
all fds but those in the list? This avoids the brain-dead assumptions about fd ordering which
closefrom() makes, but makes it easy to leave just a select few fds open for the child. As
the
parent comment points out, any code which relies on leaving fds other than stdout/stdin/
stderr open for the child probably knows exactly which fds the child will need.