File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pub(crate) type size_t = usize;
10
10
pub ( crate ) use linux_raw_sys:: ctypes:: * ;
11
11
pub ( crate ) use linux_raw_sys:: errno:: { EBADF , EINVAL } ;
12
12
pub ( 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 } ;
14
14
// Import the kernel's `uid_t` and `gid_t` if they're 32-bit.
15
15
#[ cfg( feature = "thread" ) ]
16
16
pub ( 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;
16
16
///
17
17
/// This is similar to `fcntl(fd, F_SETFD, FD_CLOEXEC)`, except that it avoids
18
18
/// 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) ) ]
20
22
#[ inline]
21
23
#[ doc( alias = "FIOCLEX" ) ]
22
24
#[ doc( alias = "FD_CLOEXEC" ) ]
@@ -28,6 +30,23 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
28
30
}
29
31
}
30
32
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
+
31
50
/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
32
51
///
33
52
/// # References
You can’t perform that action at this time.
0 commit comments