@@ -9,12 +9,13 @@ mod error;
99use crate :: error:: ChrootError ;
1010use clap:: { Arg , ArgAction , Command } ;
1111use std:: ffi:: CString ;
12- use std:: io:: Error ;
12+ use std:: io:: { Error , ErrorKind } ;
1313use std:: os:: unix:: prelude:: OsStrExt ;
14+ use std:: os:: unix:: process:: CommandExt ;
1415use std:: path:: { Path , PathBuf } ;
1516use std:: process;
1617use uucore:: entries:: { Locate , Passwd , grp2gid, usr2uid} ;
17- use uucore:: error:: { UResult , UUsageError , set_exit_code } ;
18+ use uucore:: error:: { UResult , UUsageError } ;
1819use uucore:: fs:: { MissingHandling , ResolveMode , canonicalize} ;
1920use uucore:: libc:: { self , chroot, setgid, setgroups, setuid} ;
2021use uucore:: { format_usage, show} ;
@@ -205,33 +206,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
205206
206207 assert ! ( !command. is_empty( ) ) ;
207208 let chroot_command = command[ 0 ] ;
208- let chroot_args = & command[ 1 ..] ;
209209
210210 // NOTE: Tests can only trigger code beyond this point if they're invoked with root permissions
211211 set_context ( & options) ?;
212212
213- let pstatus = match process:: Command :: new ( chroot_command)
214- . args ( chroot_args)
215- . status ( )
216- {
217- Ok ( status) => status,
218- Err ( e) => {
219- return Err ( if e. kind ( ) == std:: io:: ErrorKind :: NotFound {
220- ChrootError :: CommandNotFound ( command[ 0 ] . to_string ( ) , e)
221- } else {
222- ChrootError :: CommandFailed ( command[ 0 ] . to_string ( ) , e)
223- }
224- . into ( ) ) ;
225- }
226- } ;
213+ let err = process:: Command :: new ( chroot_command)
214+ . args ( & command[ 1 ..] )
215+ . exec ( ) ;
227216
228- let code = if pstatus . success ( ) {
229- 0
217+ Err ( if err . kind ( ) == ErrorKind :: NotFound {
218+ ChrootError :: CommandNotFound ( chroot_command . to_owned ( ) , err )
230219 } else {
231- pstatus. code ( ) . unwrap_or ( -1 )
232- } ;
233- set_exit_code ( code) ;
234- Ok ( ( ) )
220+ ChrootError :: CommandFailed ( chroot_command. to_owned ( ) , err)
221+ }
222+ . into ( ) )
235223}
236224
237225pub fn uu_app ( ) -> Command {
0 commit comments