From dc96e8ec479a40492d386938bcff04dc5e132337 Mon Sep 17 00:00:00 2001 From: rfm Date: Tue, 14 Nov 2023 19:56:43 +0000 Subject: [PATCH] more options to close descriptors (for portability) --- Source/NSTask.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/NSTask.m b/Source/NSTask.m index 0c42e13ea..cd14e50fa 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -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