feat(runtime): kill existing processes on error
This commit is contained in:
parent
924a7462bd
commit
c1881bb7b2
1 changed files with 9 additions and 1 deletions
|
@ -12,7 +12,10 @@ use nix::{
|
||||||
errno::Errno,
|
errno::Errno,
|
||||||
fcntl::OFlag,
|
fcntl::OFlag,
|
||||||
libc,
|
libc,
|
||||||
sys::wait::{self, WaitPidFlag, WaitStatus},
|
sys::{
|
||||||
|
signal,
|
||||||
|
wait::{self, WaitPidFlag, WaitStatus},
|
||||||
|
},
|
||||||
unistd::{self, Pid},
|
unistd::{self, Pid},
|
||||||
};
|
};
|
||||||
use oyster_parser::ast::{self, Redirect};
|
use oyster_parser::ast::{self, Redirect};
|
||||||
|
@ -125,6 +128,11 @@ impl Shell {
|
||||||
wait_pgid(pgid)
|
wait_pgid(pgid)
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
if status.is_err() && pgid != Pid::from_raw(0) {
|
||||||
|
let _ = signal::killpg(pgid, signal::Signal::SIGTERM);
|
||||||
|
let _ = signal::killpg(pgid, signal::Signal::SIGCONT);
|
||||||
|
}
|
||||||
|
|
||||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpgid(None).unwrap());
|
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpgid(None).unwrap());
|
||||||
|
|
||||||
status
|
status
|
||||||
|
|
Loading…
Reference in a new issue