File tree 2 files changed +7
-3
lines changed
library/std/src/sys/unix/process
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -748,7 +748,7 @@ impl Command {
748
748
msg. msg_controllen = mem:: size_of :: < Cmsg > ( ) as _ ;
749
749
msg. msg_control = & mut cmsg as * mut _ as * mut _ ;
750
750
751
- match cvt_r ( || libc:: recvmsg ( sock. as_raw ( ) , & mut msg, 0 ) ) {
751
+ match cvt_r ( || libc:: recvmsg ( sock. as_raw ( ) , & mut msg, libc :: MSG_CMSG_CLOEXEC ) ) {
752
752
Err ( _) => return -1 ,
753
753
Ok ( _) => { }
754
754
}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ fn test_command_fork_no_unwind() {
64
64
#[ test]
65
65
#[ cfg( target_os = "linux" ) ]
66
66
fn test_command_pidfd ( ) {
67
- use crate :: os:: fd:: RawFd ;
67
+ use crate :: os:: fd:: { AsRawFd , RawFd } ;
68
68
use crate :: os:: linux:: process:: { ChildExt , CommandExt } ;
69
69
use crate :: process:: Command ;
70
70
@@ -82,6 +82,10 @@ fn test_command_pidfd() {
82
82
83
83
// but only check if we know that the kernel supports pidfds
84
84
if pidfd_open_available {
85
- assert ! ( child. pidfd( ) . is_ok( ) )
85
+ assert ! ( child. pidfd( ) . is_ok( ) ) ;
86
+ }
87
+ if let Ok ( pidfd) = child. pidfd ( ) {
88
+ let flags = super :: cvt ( unsafe { libc:: fcntl ( pidfd. as_raw_fd ( ) , libc:: F_GETFD ) } ) . unwrap ( ) ;
89
+ assert ! ( flags & libc:: FD_CLOEXEC != 0 ) ;
86
90
}
87
91
}
You can’t perform that action at this time.
0 commit comments