From 4bacd01a8e1fa1909d5f1c85ebc39fa462b5c022 Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Tue, 25 May 2021 11:40:54 +0800 Subject: [PATCH] Set FD_CLOEXEC for duped epoll_fd 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 --- src/sys/unix/selector/epoll.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys/unix/selector/epoll.rs b/src/sys/unix/selector/epoll.rs index 76ee7f91a..997a54b12 100644 --- a/src/sys/unix/selector/epoll.rs +++ b/src/sys/unix/selector/epoll.rs @@ -41,7 +41,7 @@ impl Selector { } pub fn try_clone(&self) -> io::Result { - 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,