From 2c6e68df0ed13da905d1950e7eb8298d6f181fb7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 7 Aug 2013 15:04:58 -0600 Subject: [PATCH] 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. --- compat/closefrom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compat/closefrom.c b/compat/closefrom.c index a5891562b..da2870a46 100644 --- a/compat/closefrom.c +++ b/compat/closefrom.c @@ -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 + } } /*