alnyan/yggdrasil: add ExitStatusExt
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
#![stable(feature = "os", since = "1.0.0")]
|
#![stable(feature = "os", since = "1.0.0")]
|
||||||
|
|
||||||
use crate::process::Command;
|
use crate::process::{Command, ExitStatus};
|
||||||
use crate::sealed::Sealed;
|
use crate::sealed::Sealed;
|
||||||
use crate::sys_common::AsInnerMut;
|
use crate::sys_common::{AsInner, AsInnerMut};
|
||||||
use yggdrasil_rt::io::RawFd;
|
use yggdrasil_rt::{io::RawFd, process::Signal};
|
||||||
|
|
||||||
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
pub trait CommandExt: Sealed {
|
pub trait CommandExt: Sealed {
|
||||||
@@ -14,6 +14,12 @@ pub trait CommandExt: Sealed {
|
|||||||
unsafe fn gain_terminal<F: Into<RawFd>>(&mut self, fd: F) -> &mut Command;
|
unsafe fn gain_terminal<F: Into<RawFd>>(&mut self, fd: F) -> &mut Command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
pub trait ExitStatusExt: Sealed {
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
fn signal(&self) -> Option<Signal>;
|
||||||
|
}
|
||||||
|
|
||||||
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
impl CommandExt for Command {
|
impl CommandExt for Command {
|
||||||
fn process_group(&mut self, pgroup: u32) -> &mut Command {
|
fn process_group(&mut self, pgroup: u32) -> &mut Command {
|
||||||
@@ -26,3 +32,10 @@ impl CommandExt for Command {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
impl ExitStatusExt for ExitStatus {
|
||||||
|
fn signal(&self) -> Option<Signal> {
|
||||||
|
self.as_inner().signal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -150,7 +150,17 @@ impl ExitStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn code(&self) -> Option<i32> {
|
pub fn code(&self) -> Option<i32> {
|
||||||
Some(i32::from(self.0))
|
match self.0 {
|
||||||
|
OsExitCode::Exited(code) => Some(code),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn signal(&self) -> Option<OsSignal> {
|
||||||
|
match self.0 {
|
||||||
|
OsExitCode::BySignal(sig) => Some(sig),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user