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,24 +65,17 @@ impl<'a> PreparedCommand<'a> {
|
||||||
cmd.stderr(self.stderr.map_or(Stdio::inherit(), Stdio::from));
|
cmd.stderr(self.stderr.map_or(Stdio::inherit(), Stdio::from));
|
||||||
cmd.process_group(pgid.as_raw());
|
cmd.process_group(pgid.as_raw());
|
||||||
|
|
||||||
{
|
|
||||||
let pgid = *pgid;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
cmd.pre_exec(move || {
|
cmd.pre_exec(move || {
|
||||||
if pgid == Pid::from_raw(0) {
|
|
||||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpid());
|
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::SIGTSTP, &default);
|
||||||
let _ = signal::sigaction(signal::Signal::SIGTTOU, &default);
|
let _ = signal::sigaction(signal::Signal::SIGTTOU, &default);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let child = match cmd.spawn() {
|
let child = match cmd.spawn() {
|
||||||
Ok(child) => child,
|
Ok(child) => child,
|
||||||
|
|
Loading…
Reference in a new issue