Skip to content

Commit

Permalink
more options to close descriptors (for portability)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Nov 14, 2023
1 parent ae9892d commit dc96e8e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/NSTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,18 @@ - (BOOL) launchAndReturnError: (NSError **)error
*/
#if defined(HAVE_CLOSEFROM)
closefrom(3);
#elif defined(F_CLOSEM)
(void)fcntl(3, F_CLOSEM, 0);
#elif defined(_SC_OPEN_MAX)
i = sysconf(_SC_OPEN_MAX);
while (i-- > 3)
{
(void)close(i);
}
#else
for (i = 3; i < NOFILE; i++)
{
(void) close(i);
(void)close(i);
}
#endif

Expand Down

0 comments on commit dc96e8e

Please sign in to comment.