@@ -150,7 +150,7 @@ impl Command {
150
150
match cvt ( syscall:: clone ( 0 ) ) ? {
151
151
0 => {
152
152
drop ( input) ;
153
- let err = self . do_exec ( theirs) ;
153
+ let Err ( err) = self . do_exec ( theirs) ;
154
154
let errno = err. raw_os_error ( ) . unwrap_or ( syscall:: EINVAL ) as u32 ;
155
155
let bytes = [
156
156
( errno >> 24 ) as u8 ,
@@ -218,7 +218,10 @@ impl Command {
218
218
}
219
219
220
220
match self . setup_io ( default, true ) {
221
- Ok ( ( _, theirs) ) => unsafe { self . do_exec ( theirs) } ,
221
+ Ok ( ( _, theirs) ) => unsafe {
222
+ let Err ( e) = self . do_exec ( theirs) ;
223
+ e
224
+ } ,
222
225
Err ( e) => e,
223
226
}
224
227
}
@@ -253,7 +256,7 @@ impl Command {
253
256
// allocation). Instead we just close it manually. This will never
254
257
// have the drop glue anyway because this code never returns (the
255
258
// child will either exec() or invoke syscall::exit)
256
- unsafe fn do_exec ( & mut self , stdio : ChildPipes ) -> io:: Error {
259
+ unsafe fn do_exec ( & mut self , stdio : ChildPipes ) -> Result < ! , io:: Error > {
257
260
if let Some ( fd) = stdio. stderr . fd ( ) {
258
261
cvt ( syscall:: dup2 ( fd, 2 , & [ ] ) ) ?;
259
262
let mut flags = cvt ( syscall:: fcntl ( 2 , syscall:: F_GETFD , 0 ) ) ?;
@@ -308,7 +311,7 @@ impl Command {
308
311
let mut file = if let Some ( program) = program {
309
312
File :: open ( program. as_os_str ( ) ) ?
310
313
} else {
311
- return io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ;
314
+ return Err ( io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ) ;
312
315
} ;
313
316
314
317
// Push all the arguments
@@ -343,7 +346,7 @@ impl Command {
343
346
meta. mode ( ) & 0o7
344
347
} ;
345
348
if mode & 1 == 0 {
346
- return io:: Error :: from_raw_os_error ( syscall:: EPERM ) ;
349
+ return Err ( io:: Error :: from_raw_os_error ( syscall:: EPERM ) ) ;
347
350
}
348
351
349
352
// Second of all, we need to actually read which interpreter it wants
@@ -389,13 +392,12 @@ impl Command {
389
392
}
390
393
391
394
if let Err ( err) = syscall:: fexec ( file. as_raw_fd ( ) , & args, & vars) {
392
- io:: Error :: from_raw_os_error ( err. errno as i32 )
395
+ Err ( io:: Error :: from_raw_os_error ( err. errno as i32 ) )
393
396
} else {
394
397
panic ! ( "return from exec without err" ) ;
395
398
}
396
399
}
397
400
398
-
399
401
fn setup_io ( & self , default : Stdio , needs_stdin : bool )
400
402
-> io:: Result < ( StdioPipes , ChildPipes ) > {
401
403
let null = Stdio :: Null ;
0 commit comments