File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 22// only-linux - pidfds are a linux-specific concept
33
44#![ feature( linux_pidfd) ]
5- use std:: os:: linux:: process:: { CommandExt , ChildExt } ;
5+ #![ feature( rustc_private) ]
6+
7+ extern crate libc;
8+
9+ use std:: io:: Error ;
10+ use std:: os:: linux:: process:: { ChildExt , CommandExt } ;
611use std:: process:: Command ;
712
13+ fn has_clone3 ( ) -> bool {
14+ let res = unsafe { libc:: syscall ( libc:: SYS_clone3 , 0 , 0 ) } ;
15+ let err = ( res == -1 )
16+ . then ( || Error :: last_os_error ( ) )
17+ . expect ( "probe syscall should not succeed" ) ;
18+ err. raw_os_error ( ) != Some ( libc:: ENOSYS )
19+ }
20+
821fn main ( ) {
22+ // pidfds require the clone3 syscall
23+ if !has_clone3 ( ) {
24+ return ;
25+ }
26+
927 // We don't assert the precise value, since the standard library
1028 // might have opened other file descriptors before our code runs.
1129 let _ = Command :: new ( "echo" )
You can’t perform that action at this time.
0 commit comments