@@ -378,6 +378,7 @@ impl Command {
378378 callback ( ) ?;
379379 }
380380
381+ let mut _reset = None ;
381382 if let Some ( envp) = maybe_envp
382383 && self . get_resolve_in_parent_path ( )
383384 && self . env_saw_path ( )
@@ -390,8 +391,9 @@ impl Command {
390391 program : & CStr ,
391392 args : & CStringArray ,
392393 envp : & CStringArray ,
393- ) -> libc:: c_int {
394- unsafe { libc:: execvpe ( program. as_ptr ( ) , args. as_ptr ( ) , envp. as_ptr ( ) ) }
394+ ) -> io:: Error {
395+ unsafe { libc:: execvpe ( program. as_ptr ( ) , args. as_ptr ( ) , envp. as_ptr ( ) ) } ;
396+ io:: Error :: last_os_error ( )
395397 }
396398
397399 // ...so if we're not gnu then use our own implementation.
@@ -400,7 +402,7 @@ impl Command {
400402 program : & CStr ,
401403 args : & CStringArray ,
402404 envp : & CStringArray ,
403- ) -> libc :: c_int {
405+ ) -> io :: Error {
404406 unsafe {
405407 let name = program. to_bytes ( ) ;
406408 let mut buffer =
@@ -433,18 +435,18 @@ impl Command {
433435 }
434436 environ = environ. add ( 1 ) ;
435437 }
436- // If execve is successful then it'll never return, thus we'll never reach this point.
437- -1
438+ // If execve is successful then it'll never return,
439+ // thus we only reach this point on failure..
440+ io:: Error :: from_raw_os_error ( libc:: ENOENT )
438441 }
439442 }
440- exec_with_env ( self . get_program_cstr ( ) , self . get_argv ( ) , envp) ;
443+ return Err ( exec_with_env ( self . get_program_cstr ( ) , self . get_argv ( ) , envp) ) ;
441444 } else if let Some ( envp) = maybe_envp {
442445 // Although we're performing an exec here we may also return with an
443446 // error from this function (without actually exec'ing) in which case we
444447 // want to be sure to restore the global environment back to what it
445448 // once was, ensuring that our temporary override, when free'd, doesn't
446449 // corrupt our process's environment.
447- let mut _reset = None ;
448450 struct Reset ( * const * const libc:: c_char ) ;
449451
450452 impl Drop for Reset {
@@ -457,8 +459,8 @@ impl Command {
457459
458460 _reset = Some ( Reset ( * sys:: env:: environ ( ) ) ) ;
459461 * sys:: env:: environ ( ) = envp. as_ptr ( ) ;
460- libc:: execvp ( self . get_program_cstr ( ) . as_ptr ( ) , self . get_argv ( ) . as_ptr ( ) ) ;
461462 }
463+ libc:: execvp ( self . get_program_cstr ( ) . as_ptr ( ) , self . get_argv ( ) . as_ptr ( ) ) ;
462464 Err ( io:: Error :: last_os_error ( ) )
463465 }
464466
0 commit comments