From f3487c43eaf7bd195808066316588c767699124f Mon Sep 17 00:00:00 2001 From: Fuu Date: Wed, 9 Oct 2024 17:54:41 +0800 Subject: [PATCH] Close-on-exec by default for received fds --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d49e055..9a406f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,7 +123,7 @@ fn recv_with_fd(socket: RawFd, bs: &mut [u8], mut fds: &mut [RawFd]) -> io::Resu }; let (mut msghdr, cmsg_layout, _) = construct_msghdr_for(&mut iov, fds.len()); let cmsg_buffer = msghdr.msg_control; - let count = libc::recvmsg(socket, &mut msghdr as *mut _, 0); + let count = libc::recvmsg(socket, &mut msghdr as *mut _, libc::MSG_CMSG_CLOEXEC); if count < 0 { let error = io::Error::last_os_error(); alloc::dealloc(cmsg_buffer as *mut _, cmsg_layout);