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,
|
||||
fcntl::OFlag,
|
||||
libc,
|
||||
sys::wait::{self, WaitPidFlag, WaitStatus},
|
||||
sys::{
|
||||
signal,
|
||||
wait::{self, WaitPidFlag, WaitStatus},
|
||||
},
|
||||
unistd::{self, Pid},
|
||||
};
|
||||
use oyster_parser::ast::{self, Redirect};
|
||||
|
@ -125,6 +128,11 @@ impl Shell {
|
|||
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());
|
||||
|
||||
status
|
||||
|
|
Loading…
Reference in a new issue