File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pub(crate) type size_t = usize;
1010pub ( crate ) use linux_raw_sys:: ctypes:: * ;
1111pub ( crate ) use linux_raw_sys:: errno:: { EBADF , EINVAL } ;
1212pub ( crate ) use linux_raw_sys:: general:: { __kernel_fd_set as fd_set, __FD_SETSIZE as FD_SETSIZE } ;
13- pub ( crate ) use linux_raw_sys:: ioctl:: { FIONBIO , FIONREAD } ;
13+ pub ( crate ) use linux_raw_sys:: ioctl:: { FIOCLEX , FIONBIO , FIONCLEX , FIONREAD } ;
1414// Import the kernel's `uid_t` and `gid_t` if they're 32-bit.
1515#[ cfg( feature = "thread" ) ]
1616pub ( crate ) use linux_raw_sys:: general:: futex_waitv;
Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ use backend::fd::AsFd;
1616///
1717/// This is similar to `fcntl(fd, F_SETFD, FD_CLOEXEC)`, except that it avoids
1818/// clearing any other flags that might be set.
19- #[ cfg( apple) ]
19+ ///
20+ /// Linux: Note that `ioctl` can not be used on `OFlags::PATH` file
21+ /// descriptors.
22+ #[ cfg( any( apple, linux_kernel) ) ]
2023#[ inline]
2124#[ doc( alias = "FIOCLEX" ) ]
2225#[ doc( alias = "FD_CLOEXEC" ) ]
@@ -28,6 +31,24 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
2831 }
2932}
3033
34+ /// `ioctl(fd, FIONCLEX, NULL)`—Remove the close-on-exec flag.
35+ ///
36+ /// This is similar to `fcntl_setfd(fd, FdFlags::empty())`, except that it avoids
37+ /// clearing any other flags that might be set.
38+ ///
39+ /// Linux: Note that `ioctl` can not be used on `OFlags::PATH` file
40+ /// descriptors.
41+ #[ cfg( any( apple, linux_kernel) ) ]
42+ #[ inline]
43+ #[ doc( alias = "FIONCLEX" ) ]
44+ pub fn ioctl_fionclex < Fd : AsFd > ( fd : Fd ) -> io:: Result < ( ) > {
45+ // SAFETY: `FIONCLEX` is a no-argument setter opcode.
46+ unsafe {
47+ let ctl = ioctl:: NoArg :: < { c:: FIONCLEX } > :: new ( ) ;
48+ ioctl:: ioctl ( fd, ctl)
49+ }
50+ }
51+
3152/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
3253///
3354/// # References
You can’t perform that action at this time.
0 commit comments