diff --git a/src/shell/pipe_exec/fork.rs b/src/shell/pipe_exec/fork.rs index c38ffd6d585b29d44637c8af29161eb85380a0d5..c0b76fc77464a4edd295236bd8d3d9943b755946 100644 --- a/src/shell/pipe_exec/fork.rs +++ b/src/shell/pipe_exec/fork.rs @@ -16,10 +16,9 @@ use std::process::exit; pub fn fork_pipe(shell: &mut Shell, commands: Vec<(RefinedJob, JobKind)>, command_name: String) -> i32 { match unsafe { sys::fork() } { Ok(0) => { - // The child fork should not have any signals blocked, so the shell can control it. - signals::unblock(); let _ = sys::reset_signal(sys::SIGINT); let _ = sys::reset_signal(sys::SIGHUP); + let _ = sys::reset_signal(sys::SIGTERM); // This ensures that the child fork has a unique PGID. create_process_group(0); // After execution of it's commands, exit with the last command's status. diff --git a/src/shell/pipe_exec/mod.rs b/src/shell/pipe_exec/mod.rs index d449bf0e4b83cb3f37a86b249d7d64c0dae370a5..250a53e3783dced0cbc717c70e41df692103aebe 100644 --- a/src/shell/pipe_exec/mod.rs +++ b/src/shell/pipe_exec/mod.rs @@ -23,7 +23,6 @@ use std::os::unix::process::CommandExt; use std::process::{exit, Command}; use sys; - /// Use dup2 to replace `old` with `new` using `old`s file descriptor ID fn redir(old: RawFd, new: RawFd) { if let Err(e) = sys::dup2(old, new) { @@ -257,6 +256,9 @@ pub fn pipe(shell: &mut Shell, commands: Vec<(RefinedJob, JobKind)>, foreground: match unsafe { sys::fork() } { Ok(0) => { signals::unblock(); + let _ = sys::reset_signal(sys::SIGINT); + let _ = sys::reset_signal(sys::SIGHUP); + let _ = sys::reset_signal(sys::SIGTERM); create_process_group(pgid); let args: Vec<&str> = args .iter() diff --git a/src/sys/unix.rs b/src/sys/unix.rs index b516fbf611e4736e7c0a056a9c061f958b14abce..a020ea7284930b0543bd7e3981a753354b4e716e 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -252,7 +252,7 @@ pub mod job_control { { let mut exit_status = 0; loop { - match wait() { + match waitpid(-1, Some(WUNTRACED)) { Ok(WaitStatus::Exited(pid, status)) => if pid == (last_pid as i32) { break status as i32; } else {