@@ -52,7 +52,7 @@ impl Command {
52
52
// in its own process. Thus the parent drops the lock guard while the child
53
53
// forgets it to avoid unlocking it on a new thread, which would be invalid.
54
54
let env_lock = sys:: os:: env_read_lock ( ) ;
55
- let ( result, pidfd) = self . do_fork ( ) ?;
55
+ let ( result, pidfd) = unsafe { self . do_fork ( ) ? } ;
56
56
57
57
let pid = unsafe {
58
58
match result {
@@ -121,14 +121,14 @@ impl Command {
121
121
// Attempts to fork the process. If successful, returns Ok((0, -1))
122
122
// in the child, and Ok((child_pid, -1)) in the parent.
123
123
#[ cfg( not( target_os = "linux" ) ) ]
124
- fn do_fork ( & mut self ) -> Result < ( pid_t , pid_t ) , io:: Error > {
125
- cvt ( unsafe { libc:: fork ( ) } ) . map ( |res| ( res, -1 ) )
124
+ unsafe fn do_fork ( & mut self ) -> Result < ( pid_t , pid_t ) , io:: Error > {
125
+ cvt ( libc:: fork ( ) ) . map ( |res| ( res, -1 ) )
126
126
}
127
127
128
128
// Attempts to fork the process. If successful, returns Ok((0, -1))
129
129
// in the child, and Ok((child_pid, child_pidfd)) in the parent.
130
130
#[ cfg( target_os = "linux" ) ]
131
- fn do_fork ( & mut self ) -> Result < ( pid_t , pid_t ) , io:: Error > {
131
+ unsafe fn do_fork ( & mut self ) -> Result < ( pid_t , pid_t ) , io:: Error > {
132
132
use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
133
133
134
134
static HAS_CLONE3 : AtomicBool = AtomicBool :: new ( true ) ;
@@ -183,7 +183,7 @@ impl Command {
183
183
let args_ptr = & mut args as * mut clone_args ;
184
184
let args_size = crate :: mem:: size_of :: < clone_args > ( ) ;
185
185
186
- let res = cvt ( unsafe { clone3 ( args_ptr, args_size) } ) ;
186
+ let res = cvt ( clone3 ( args_ptr, args_size) ) ;
187
187
match res {
188
188
Ok ( n) => return Ok ( ( n as pid_t , pidfd) ) ,
189
189
Err ( e) => match e. raw_os_error ( ) {
@@ -201,7 +201,7 @@ impl Command {
201
201
202
202
// If we get here, the 'clone3' syscall does not exist
203
203
// or we do not have permission to call it
204
- cvt ( unsafe { libc:: fork ( ) } ) . map ( |res| ( res, pidfd) )
204
+ cvt ( libc:: fork ( ) ) . map ( |res| ( res, pidfd) )
205
205
}
206
206
207
207
pub fn exec ( & mut self , default : Stdio ) -> io:: Error {
0 commit comments