fix(runtime): grab terminal even if error occured
This commit is contained in:
parent
f0698457ed
commit
924a7462bd
1 changed files with 17 additions and 16 deletions
|
@ -101,8 +101,9 @@ impl Shell {
|
|||
&mut self,
|
||||
pipeline: &ast::Pipeline,
|
||||
) -> Result<Status, RuntimeError> {
|
||||
let mut cmds = pipeline.0.iter().map(PreparedCommand::from);
|
||||
let mut pgid = Pid::from_raw(0);
|
||||
let status = (|| {
|
||||
let mut cmds = pipeline.0.iter().map(PreparedCommand::from);
|
||||
|
||||
let mut last_cmd = cmds.next().expect("pipelines need to have >1 commands");
|
||||
for mut cmd in cmds {
|
||||
|
@ -121,12 +122,12 @@ impl Shell {
|
|||
|
||||
last_cmd.spawn(&mut pgid)?;
|
||||
|
||||
// TODO: kill children if error occured
|
||||
wait_pgid(pgid)
|
||||
})();
|
||||
|
||||
let status = wait_pgid(pgid)?;
|
||||
let _ = unistd::tcsetpgrp(libc::STDIN_FILENO, unistd::getpgid(None).unwrap());
|
||||
|
||||
Ok(status)
|
||||
status
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue