diff options
| author | akbash <akbash@herdr.dev> | 2026-08-19 20:39:24 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-19 20:39:24 +0300 |
| commit | e3c3d443584b629803a73ad66e0e298943c7f201 (patch) | |
| tree | 639abd8b3d8f03d07d05eef47ca025cafaeda02b /src/platform/unix_common.rs | |
| parent | 5203a5dc0f39a082938ea0f9836d6257ea7e155f (diff) | |
fix(cli): exit quietly when output pipes close (#2996)
refs #2994
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/platform/unix_common.rs')
| -rw-r--r-- | src/platform/unix_common.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index fa7b6d20..b997049f 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -1,5 +1,24 @@ use std::path::{Path, PathBuf}; +fn set_sigpipe_disposition(handler: libc::sighandler_t) { + let mut action: libc::sigaction = unsafe { std::mem::zeroed() }; + action.sa_sigaction = handler; + unsafe { + libc::sigemptyset(&mut action.sa_mask); + // Rust starts with SIGPIPE ignored. If this best-effort transition + // fails, stdout retains the existing Rust behavior. + libc::sigaction(libc::SIGPIPE, &action, std::ptr::null_mut()); + } +} + +pub(crate) fn begin_cli_output() { + set_sigpipe_disposition(libc::SIG_DFL); +} + +pub(crate) fn end_cli_output() { + set_sigpipe_disposition(libc::SIG_IGN); +} + pub(crate) fn remote_ssh_config_paths() -> super::RemoteSshConfigPaths { super::RemoteSshConfigPaths { user_config: std::env::var_os("HOME") |
