Avoid a crash on Mac OS X 10.8 (at least) when we close libdispatch's

fds out from under it before executing the command.  Switch to just
setting the close on exec flag instead.
This commit is contained in:
Todd C. Miller
2013-08-07 15:04:58 -06:00
parent 30adf33eaf
commit 2c6e68df0e

View File

@@ -83,8 +83,14 @@ closefrom_fallback(int lowfd)
if (maxfd < 0)
maxfd = OPEN_MAX;
for (fd = lowfd; fd < maxfd; fd++)
for (fd = lowfd; fd < maxfd; fd++) {
#ifdef __APPLE__
/* Avoid potential crash with libdispatch when we close its fds. */
(void) fcntl(fd, F_SETFD, FD_CLOEXEC);
#else
(void) close((int) fd);
#endif
}
}
/*