diff options
Diffstat (limited to 'crates/dinggerd/src/platform.rs')
| -rw-r--r-- | crates/dinggerd/src/platform.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/dinggerd/src/platform.rs b/crates/dinggerd/src/platform.rs index 8504a83..6c78817 100644 --- a/crates/dinggerd/src/platform.rs +++ b/crates/dinggerd/src/platform.rs @@ -1,4 +1,21 @@ -//! macOS process inspection. +//! macOS process inspection and process setup. + +/// Exit quietly when stdout closes early (`dingger restore --list | head`), +/// like other command-line tools, instead of panicking: Rust ignores +/// SIGPIPE by default. +#[cfg(unix)] +pub fn default_sigpipe() { + extern "C" { + fn signal(signum: std::os::raw::c_int, handler: usize) -> usize; + } + const SIGPIPE: std::os::raw::c_int = 13; + const SIG_DFL: usize = 0; + // SAFETY: resets one signal to its default disposition before any + // threads start. + unsafe { + signal(SIGPIPE, SIG_DFL); + } +} /// A process's exact argument vector, from the kernel (`KERN_PROCARGS2`): /// unlike `ps`, it keeps arguments that contain spaces intact. |
