do away with wierd process waits
Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
48178b5a48
commit
1993f39d93
1 changed files with 17 additions and 25 deletions
|
|
@ -42,9 +42,7 @@ use {
|
|||
env::set_current_dir,
|
||||
os::unix::process::CommandExt,
|
||||
mem,
|
||||
thread,
|
||||
process,
|
||||
time::Duration,
|
||||
},
|
||||
nix::{
|
||||
unistd, unistd::Pid,
|
||||
|
|
@ -228,31 +226,25 @@ fn make_foreground(pid: u32, state: &mut ShellState) -> Result<(), String> {
|
|||
|
||||
|
||||
loop {
|
||||
match i.try_wait() {
|
||||
match i.wait() {
|
||||
Ok(maybe) => {
|
||||
if let Some(exit) = maybe {
|
||||
if let Err(e) = unistd::tcsetpgrp(0, state.parent_pid) {
|
||||
return Err(format!(
|
||||
"error re-acquiring terminal: {}!", e
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: this could be more elegant
|
||||
if let Some(ref attr) = state.attr {
|
||||
tcsetattr(0, SetArg::TCSADRAIN, attr).ok();
|
||||
} else {
|
||||
panic!("somehow no attrs")
|
||||
}
|
||||
|
||||
state.last_exit_code = exit
|
||||
state.last_exit_code = maybe
|
||||
.code()
|
||||
.unwrap_or(-1);
|
||||
|
||||
break;
|
||||
} else {
|
||||
// sleep 1 sec
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
return Err(format!("error waiting on child: {}", e))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue