Skip to content

Commit

Permalink
Set FD_CLOEXEC for duped epoll_fd
Browse files Browse the repository at this point in the history
The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off
and we should set it manually.

Fixes: tokio-rs/tokio#3809

Signed-off-by: Tim Zhang <[email protected]>
  • Loading branch information
Tim-Zhang authored and Thomasdezeeuw committed Jun 11, 2021
1 parent 772c692 commit d1617b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Selector {
}

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

0 comments on commit d1617b5

Please sign in to comment.