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;
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,10 @@ 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 `OFlags::PATH` file
21
+ /// descriptors.
22
+ #[ cfg( any( apple, linux_kernel) ) ]
20
23
#[ inline]
21
24
#[ doc( alias = "FIOCLEX" ) ]
22
25
#[ doc( alias = "FD_CLOEXEC" ) ]
@@ -28,6 +31,24 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
28
31
}
29
32
}
30
33
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
+
31
52
/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
32
53
///
33
54
/// # References
You can’t perform that action at this time.
0 commit comments