| 209 | #[cfg(unix)] |
| 210 | #[allow(unsafe_code)] |
| 211 | fn reset_transient_tty_signals(command: &mut Command) { |
| 212 | // SAFETY: `pre_exec` runs in the forked child immediately before `exec`. |
| 213 | // We only reset a small fixed set of signal handlers to `SIG_DFL`, which is |
| 214 | // required so SSH receives terminal signals normally even though the parent |
| 215 | // process temporarily ignores them to preserve cleanup. |
| 216 | unsafe { |
| 217 | command.pre_exec(|| { |
| 218 | for &signal in TRANSIENT_TTY_SIGNALS { |
| 219 | let action = SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty()); |
| 220 | sigaction(signal, &action).map_err(|err| std::io::Error::other(err.to_string()))?; |
| 221 | } |
| 222 | Ok(()) |
| 223 | }); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | fn exec_or_wait(mut command: Command, replace_process: bool) -> Result<()> { |
| 228 | if replace_process && std::io::stdin().is_terminal() { |