Skip to content

Commit

Permalink
workaround for F_DUPFD_CLOEXEC on Linux kernel <2.6.24 before it existed
Browse files Browse the repository at this point in the history
  • Loading branch information
marius311 committed Dec 11, 2018
1 parent 560e829 commit 0e18677
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,15 @@ int uv_dup(uv_os_fd_t fd, uv_os_fd_t* dupfd) {
}
#else
int uv_dup(uv_os_fd_t fd, uv_os_fd_t* dupfd) {
// F_DUPFD_CLOEXEC only available since Linux 2.6.24
#ifdef F_DUPFD_CLOEXEC
if ((*dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) == -1)
return -errno;
#else
if ((*dupfd = fcntl(fd, F_DUPFD, 3)) == -1)
return -errno;
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
return 0;
}
#endif
Expand Down

0 comments on commit 0e18677

Please sign in to comment.