Use the closefrom system call if available to close all fds.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 10 Apr 2011 19:21:06 +0000 (19:21 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 10 Apr 2011 21:35:03 +0000 (21:35 +0000)
commit43be79e71144d5be6ac7dbe6a26c5ef32266e779
tree95565acfbca32559643af8b8bb735ba917c30cb6
parent085825e838a001d00fd016c2a6d614cdc620a0dc
Use the closefrom system call if available to close all fds.

If not available, fall back to fcntl(F_CLOSEM); if that's not
available, fall back to closing all fds up to and including
fcntl(F_MAXFD); if that's not available, fall back to closing all
fds below UX_SC_OPEN_MAX like before.

Each case tested under NetBSD by running runtime/test-process.scm,
evaluating (RUN-SHELL-COMMAND "ls"), and ktracing Scheme during

   (RUN-SUBPROCESS-IN-FOREGROUND "/usr/bin/true" '#("true") '#())

with `ktrace -d -i' to make sure that it uses the right sequence of
system calls.
src/microcode/configure.ac
src/microcode/ux.c
src/microcode/ux.h
src/microcode/uxproc.c