Skip to content

Commit c52635c

Browse files
Tim-ZhangThomasdezeeuw
authored andcommitted
Set the close-on-exec flag for the duplicate epoll_fd
The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor created by dup(2) is off. We can use fcntl + F_DUPFD_CLOEXEC to dup the epoll_fd to fix this issue. Fixes: tokio-rs/tokio#3809 Signed-off-by: Tim Zhang <[email protected]>
1 parent 2246ffb commit c52635c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sys/unix/selector/epoll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Selector {
4141
}
4242

4343
pub fn try_clone(&self) -> io::Result<Selector> {
44-
syscall!(dup(self.ep)).map(|ep| Selector {
44+
syscall!(fcntl(self.ep, libc::F_DUPFD_CLOEXEC, 0)).map(|ep| Selector {
4545
// It's the same selector, so we use the same id.
4646
#[cfg(debug_assertions)]
4747
id: self.id,

0 commit comments

Comments
 (0)