fix(runtime): set fg pgrp in all children
Before there was a race condition, where it relied on the scheduler running the first child first.
This commit is contained in:
parent
f0e15804b4
commit
6c759e57cc
1 changed files with 8 additions and 15 deletions
|
@ -65,23 +65,16 @@ impl<'a> PreparedCommand<'a> {
|
|||
cmd.stderr(self.stderr.map_or(Stdio::inherit(), Stdio::from));
|
||||
cmd.process_group(pgid.as_raw());
|
||||
|
||||
{
|
||||
let pgid = *pgid;
|
||||
unsafe {
|
||||
cmd.pre_exec(move || {
|
||||
if pgid == Pid::from_raw(0) {
|
||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpid());
|
||||
}
|
||||
unsafe {
|
||||
cmd.pre_exec(move || {
|
||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpid());
|
||||
|
||||
let default =
|
||||
SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty());
|
||||
let default = SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty());
|
||||
let _ = signal::sigaction(signal::Signal::SIGTSTP, &default);
|
||||
let _ = signal::sigaction(signal::Signal::SIGTTOU, &default);
|
||||
|
||||
let _ = signal::sigaction(signal::Signal::SIGTSTP, &default);
|
||||
let _ = signal::sigaction(signal::Signal::SIGTTOU, &default);
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
let child = match cmd.spawn() {
|
||||
|
|
Loading…
Reference in a new issue