Created
October 21, 2025 13:08
-
-
Save gszr/35d31451f0df03dea94bbf2d80313d7c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| diff --git i/src/run.rs w/src/run.rs | |
| index c978e6a..8e61cf7 100644 | |
| --- i/src/run.rs | |
| +++ w/src/run.rs | |
| @@ -53,54 +53,13 @@ pub(crate) fn run(mut cmd: Command) -> i32 { | |
| } | |
| }; | |
| - let old_mask = mask | |
| - .thread_swap_mask(SIG_BLOCK) | |
| - .expect("failed to block signals"); | |
| + // Wait for the child process to complete and get its exit status. | |
| + // The `expect` call will panic if waiting fails (e.g., due to an OS error). | |
| + let exit_status = proc.wait() | |
| + .expect("Failed to wait on child process"); | |
| - let caught = loop { | |
| - // we need to check if the child process has exited some time between | |
| - // when we set up our signal mask and now | |
| - if let Ok(Some(_)) = proc.try_wait() { | |
| - break SIGCHLD; | |
| - } | |
| - | |
| - let signal = mask.wait().expect("failed to wait for signal"); | |
| - | |
| - if signal == SIGWINCH { | |
| - send_signal(&proc, SIGWINCH); | |
| - } else { | |
| - break signal; | |
| - } | |
| - }; | |
| - | |
| - old_mask | |
| - .thread_set_mask() | |
| - .expect("failed to restore thread signal mask"); | |
| - | |
| - match caught { | |
| - SIGCHLD => block_wait(proc), | |
| - SIGINT => { | |
| - send_then_kill(&proc, SIGQUIT); | |
| - block_wait(proc); | |
| - 128 + SIGINT as i32 | |
| - } | |
| - SIGPIPE => { | |
| - send_then_kill(&proc, SIGQUIT); | |
| - block_wait(proc); | |
| - 128 + SIGPIPE as i32 | |
| - } | |
| - SIGHUP => { | |
| - send_signal(&proc, SIGQUIT); | |
| - block_wait(proc) | |
| - } | |
| - SIGTERM => { | |
| - send_signal(&proc, SIGTERM); | |
| - block_wait(proc); | |
| - 128 + SIGTERM as i32 | |
| - } | |
| - other => { | |
| - send_signal(&proc, other); | |
| - block_wait(proc) | |
| - } | |
| + match exit_status.code() { | |
| + Some(code) => code, | |
| + None => -1 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment