-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ExitStatusExt::aborted_code for Fuchsia platform
- Loading branch information
Showing
5 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Fuchsia-specific extensions to primitives in the [`std::process`] module. | ||
//! | ||
//! [`std::process`]: crate::process | ||
use crate::process; | ||
use crate::sealed::Sealed; | ||
|
||
// On Zircon (the Fuchsia kernel), an abort from userspace calls the | ||
// LLVM implementation of __builtin_trap(), e.g., ud2 on x86, which | ||
// raises a kernel exception. If a userspace process does not | ||
// otherwise arrange exception handling, the kernel kills the process | ||
// with this return code. | ||
const ZX_TASK_RETCODE_EXCEPTION_KILL: i32 = -1028; | ||
|
||
#[unstable(feature = "fuchsia_exit_status", issue = "none")] | ||
pub trait ExitStatusExt: Sealed { | ||
/// If the process was aborted, returns the status code. | ||
#[must_use] | ||
fn aborted_code(&self) -> Option<i32>; | ||
} | ||
|
||
#[unstable(feature = "fuchsia_exit_status", issue = "none")] | ||
impl ExitStatusExt for process::ExitStatus { | ||
/// If the process was aborted, returns the status code. | ||
fn aborted_code(&self) -> Option<i32> { | ||
match self.code() { | ||
code @ Some(ZX_TASK_RETCODE_EXCEPTION_KILL) => code, | ||
Some(_) | None => None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters