@@ -150,7 +150,7 @@ impl Command {
150150 match cvt ( syscall:: clone ( 0 ) ) ? {
151151 0 => {
152152 drop ( input) ;
153- let err = self . do_exec ( theirs) ;
153+ let Err ( err) = self . do_exec ( theirs) ;
154154 let errno = err. raw_os_error ( ) . unwrap_or ( syscall:: EINVAL ) as u32 ;
155155 let bytes = [
156156 ( errno >> 24 ) as u8 ,
@@ -218,7 +218,10 @@ impl Command {
218218 }
219219
220220 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+ } ,
222225 Err ( e) => e,
223226 }
224227 }
@@ -253,7 +256,7 @@ impl Command {
253256 // allocation). Instead we just close it manually. This will never
254257 // have the drop glue anyway because this code never returns (the
255258 // 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 > {
257260 if let Some ( fd) = stdio. stderr . fd ( ) {
258261 cvt ( syscall:: dup2 ( fd, 2 , & [ ] ) ) ?;
259262 let mut flags = cvt ( syscall:: fcntl ( 2 , syscall:: F_GETFD , 0 ) ) ?;
@@ -308,7 +311,7 @@ impl Command {
308311 let mut file = if let Some ( program) = program {
309312 File :: open ( program. as_os_str ( ) ) ?
310313 } else {
311- return io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ;
314+ return Err ( io:: Error :: from_raw_os_error ( syscall:: ENOENT ) ) ;
312315 } ;
313316
314317 // Push all the arguments
@@ -343,7 +346,7 @@ impl Command {
343346 meta. mode ( ) & 0o7
344347 } ;
345348 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 ) ) ;
347350 }
348351
349352 // Second of all, we need to actually read which interpreter it wants
@@ -389,13 +392,12 @@ impl Command {
389392 }
390393
391394 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 ) )
393396 } else {
394397 panic ! ( "return from exec without err" ) ;
395398 }
396399 }
397400
398-
399401 fn setup_io ( & self , default : Stdio , needs_stdin : bool )
400402 -> io:: Result < ( StdioPipes , ChildPipes ) > {
401403 let null = Stdio :: Null ;
0 commit comments