@@ -2,6 +2,7 @@ use super::env::{CommandEnv, CommandEnvs};
22pub use crate :: ffi:: OsString as EnvKey ;
33use crate :: ffi:: { OsStr , OsString } ;
44use crate :: num:: NonZero ;
5+ use crate :: os:: safaos:: ResourceID ;
56use crate :: os:: safaos:: api:: errors:: ErrorStatus ;
67use crate :: os:: safaos:: api:: syscalls;
78use crate :: path:: Path ;
@@ -51,7 +52,7 @@ pub enum Stdio {
5152
5253impl Stdio {
5354 // `&self` because Self::InheritFile has to live as long as the results
54- fn into_raw ( & self ) -> Option < usize > {
55+ fn into_raw ( & self ) -> Option < ResourceID > {
5556 match self {
5657 Stdio :: Inherit => None ,
5758 Stdio :: InheritStdout => Some ( sysget_stdout ( ) ) ,
@@ -292,14 +293,13 @@ impl fmt::Debug for Command {
292293
293294#[ derive( PartialEq , Eq , Clone , Copy , Debug , Default ) ]
294295#[ non_exhaustive]
295- pub struct ExitStatus ( u32 ) ;
296+ pub struct ExitStatus ( isize ) ;
296297
297298impl ExitStatus {
298299 pub fn exit_ok ( & self ) -> Result < ( ) , ExitStatusError > {
299- match SysResult :: try_from ( self . 0 as u16 ) {
300- Ok ( SysResult :: Success ) => Ok ( ( ) ) ,
301- Ok ( SysResult :: Error ( e) ) => Err ( ExitStatusError :: ErrorStatus ( e) ) ,
302- Err ( _) => Err ( ExitStatusError :: Unknown ( self . 0 as u32 ) ) ,
300+ match SysResult :: from_isize ( self . 0 ) . into_result ( ) {
301+ Ok ( _) => Ok ( ( ) ) ,
302+ Err ( e) => Err ( ExitStatusError ( e) ) ,
303303 }
304304 }
305305
@@ -311,24 +311,19 @@ impl ExitStatus {
311311impl fmt:: Display for ExitStatus {
312312 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
313313 match self . exit_ok ( ) {
314- Ok ( ( ) ) => write ! ( f, "{}" , " Success") ,
314+ Ok ( ( ) ) => write ! ( f, "Success" ) ,
315315 Err ( err) => write ! ( f, "{}" , err) ,
316316 }
317317 }
318318}
319319
320320#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
321- pub enum ExitStatusError {
322- ErrorStatus ( ErrorStatus ) ,
323- Unknown ( u32 ) ,
324- }
321+ #[ repr( transparent) ]
322+ pub struct ExitStatusError ( ErrorStatus ) ;
325323
326324impl core:: fmt:: Display for ExitStatusError {
327325 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
328- match self {
329- Self :: ErrorStatus ( err) => write ! ( f, "{}" , err. as_str( ) ) ,
330- Self :: Unknown ( code) => write ! ( f, "<unknown exit status {}>" , code) ,
331- }
326+ write ! ( f, "{}" , self . 0 . as_str( ) )
332327 }
333328}
334329
@@ -341,10 +336,7 @@ impl ExitStatusError {
341336
342337impl Into < ExitStatus > for ExitStatusError {
343338 fn into ( self ) -> ExitStatus {
344- match self {
345- Self :: ErrorStatus ( err) => ExitStatus ( err as u32 ) ,
346- Self :: Unknown ( code) => ExitStatus ( code) ,
347- }
339+ ExitStatus ( -( self . 0 as isize ) )
348340 }
349341}
350342
@@ -385,12 +377,12 @@ impl Process {
385377
386378 pub fn wait ( & mut self ) -> io:: Result < ExitStatus > {
387379 let exit_code = syscalls:: process:: wait ( self . 0 ) ?;
388- Ok ( ExitStatus ( exit_code as u32 ) )
380+ Ok ( ExitStatus ( exit_code as isize ) )
389381 }
390382
391383 pub fn try_wait ( & mut self ) -> io:: Result < Option < ExitStatus > > {
392384 let exit_code = syscalls:: process:: try_cleanup ( self . 0 ) ?;
393- Ok ( exit_code. map ( |code| ExitStatus ( code as u32 ) ) )
385+ Ok ( exit_code. map ( |code| ExitStatus ( code as isize ) ) )
394386 }
395387}
396388
0 commit comments