diff --git a/crates/oyster_runtime/src/pipeline.rs b/crates/oyster_runtime/src/pipeline.rs index 8bc5e0f..ae4a62c 100644 --- a/crates/oyster_runtime/src/pipeline.rs +++ b/crates/oyster_runtime/src/pipeline.rs @@ -13,7 +13,8 @@ use nix::{ fcntl::OFlag, libc, sys::{ - signal, + signal::{self, SaFlags, SigAction, SigHandler}, + signalfd::SigSet, wait::{self, WaitPidFlag, WaitStatus}, }, unistd::{self, Pid}, @@ -47,10 +48,20 @@ impl<'a> PreparedCommand<'a> { cmd.stderr(self.stderr.map_or(Stdio::inherit(), Stdio::from)); cmd.process_group(pgid.as_raw()); - if *pgid == Pid::from_raw(0) { + { + let pgid = *pgid; unsafe { cmd.pre_exec(move || { - let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpid()); + if pgid == Pid::from_raw(0) { + let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpid()); + } + + let default = + SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty()); + + let _ = signal::sigaction(signal::Signal::SIGTSTP, &default); + let _ = signal::sigaction(signal::Signal::SIGTTOU, &default); + Ok(()) }); }