Skip to content

Commit 5cd5dba

Browse files
committed
Don't use separate close_fds.c file
1 parent 6470686 commit 5cd5dba

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

cbits/posix/close_fds.c

Lines changed: 0 additions & 22 deletions
This file was deleted.

cbits/posix/runProcess.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
#include <signal.h>
2020
#endif
2121

22+
#if defined(HAVE_CLOSERANGE)
23+
#include <linux/close_range.h>
24+
#endif
25+
26+
void
27+
closefrom_excluding(int lowfd, int excludingFd) {
28+
#if defined(HAVE_CLOSERANGE)
29+
close_range(lowfd, excludingFd - 1);
30+
closefrom(excludingFd + 1);
31+
#else
32+
for (int i = lowfd; i < excludingFd; i++) {
33+
close(i);
34+
}
35+
36+
closefrom(excludingFd + 1);
37+
#endif
38+
}
2239

2340
// If a process was terminated by a signal, the exit status we return
2441
// via the System.Process API is (-signum). This encoding avoids collision with

process.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ library
6767
c-sources:
6868
cbits/posix/runProcess.c
6969
cbits/posix/bsd_closefrom.c
70-
cbits/posix/close_fds.c
7170
cbits/posix/fork_exec.c
7271
cbits/posix/posix_spawn.c
7372
cbits/posix/find_executable.c

0 commit comments

Comments
 (0)