Skip to content

Commit 0e18677

Browse files
committed
workaround for F_DUPFD_CLOEXEC on Linux kernel <2.6.24 before it existed
1 parent 560e829 commit 0e18677

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/init.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,15 @@ int uv_dup(uv_os_fd_t fd, uv_os_fd_t* dupfd) {
345345
}
346346
#else
347347
int uv_dup(uv_os_fd_t fd, uv_os_fd_t* dupfd) {
348+
// F_DUPFD_CLOEXEC only available since Linux 2.6.24
349+
#ifdef F_DUPFD_CLOEXEC
348350
if ((*dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) == -1)
349351
return -errno;
352+
#else
353+
if ((*dupfd = fcntl(fd, F_DUPFD, 3)) == -1)
354+
return -errno;
355+
fcntl(fd, F_SETFD, FD_CLOEXEC);
356+
#endif
350357
return 0;
351358
}
352359
#endif

0 commit comments

Comments
 (0)