File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
library/std/src/sys/unix/process Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -748,7 +748,7 @@ impl Command {
748748 msg. msg_controllen = mem:: size_of :: < Cmsg > ( ) as _ ;
749749 msg. msg_control = & mut cmsg as * mut _ as * mut _ ;
750750
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 ) ) {
752752 Err ( _) => return -1 ,
753753 Ok ( _) => { }
754754 }
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ fn test_command_fork_no_unwind() {
6464#[ test]
6565#[ cfg( target_os = "linux" ) ]
6666fn test_command_pidfd ( ) {
67- use crate :: os:: fd:: RawFd ;
67+ use crate :: os:: fd:: { AsRawFd , RawFd } ;
6868 use crate :: os:: linux:: process:: { ChildExt , CommandExt } ;
6969 use crate :: process:: Command ;
7070
@@ -82,6 +82,10 @@ fn test_command_pidfd() {
8282
8383 // but only check if we know that the kernel supports pidfds
8484 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 ) ;
8690 }
8791}
You can’t perform that action at this time.
0 commit comments