We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52afbdc commit 1b98ac6Copy full SHA for 1b98ac6
1 file changed
src/unix/pty.cc
@@ -113,6 +113,17 @@ struct ExitEvent {
113
};
114
115
#if defined(__linux__)
116
+
117
+static int
118
+SetCloseOnExec(int fd) {
119
+ int flags = fcntl(fd, F_GETFD, 0);
120
+ if (flags == -1)
121
+ return flags;
122
+ if (flags & FD_CLOEXEC)
123
+ return 0;
124
+ return fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
125
+}
126
127
/**
128
* Close all file descriptors >= 3 to prevent FD leakage to child processes.
129
* Uses close_range() syscall on Linux 5.9+, falls back to /proc/self/fd iteration.
0 commit comments