File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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,9 @@ 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 `O_PATH` file descriptors.
21+ #[ cfg( any( apple, linux_kernel) ) ]
2022#[ inline]
2123#[ doc( alias = "FIOCLEX" ) ]
2224#[ doc( alias = "FD_CLOEXEC" ) ]
@@ -28,6 +30,23 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
2830 }
2931}
3032
33+ /// `ioctl(fd, FIONCLEX, NULL)`—Remove the close-on-exec flag.
34+ ///
35+ /// This is similar to `fcntl(fd, F_SETFD, 0)`, except that it avoids
36+ /// clearing any other flags that might be set.
37+ ///
38+ /// Linux: Note that `ioctl` can not be used on `O_PATH` file descriptors.
39+ #[ cfg( any( apple, linux_kernel) ) ]
40+ #[ inline]
41+ #[ doc( alias = "FIONCLEX" ) ]
42+ pub fn ioctl_fionclex < Fd : AsFd > ( fd : Fd ) -> io:: Result < ( ) > {
43+ // SAFETY: `FIONCLEX` is a no-argument setter opcode.
44+ unsafe {
45+ let ctl = ioctl:: NoArg :: < { c:: FIONCLEX } > :: new ( ) ;
46+ ioctl:: ioctl ( fd, ctl)
47+ }
48+ }
49+
3150/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
3251///
3352/// # References
You can’t perform that action at this time.
0 commit comments