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,
|
env::set_current_dir,
|
||||||
os::unix::process::CommandExt,
|
os::unix::process::CommandExt,
|
||||||
mem,
|
mem,
|
||||||
thread,
|
|
||||||
process,
|
process,
|
||||||
time::Duration,
|
|
||||||
},
|
},
|
||||||
nix::{
|
nix::{
|
||||||
unistd, unistd::Pid,
|
unistd, unistd::Pid,
|
||||||
|
|
@ -228,31 +226,25 @@ fn make_foreground(pid: u32, state: &mut ShellState) -> Result<(), String> {
|
||||||
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match i.try_wait() {
|
match i.wait() {
|
||||||
Ok(maybe) => {
|
Ok(maybe) => {
|
||||||
if let Some(exit) = maybe {
|
|
||||||
if let Err(e) = unistd::tcsetpgrp(0, state.parent_pid) {
|
if let Err(e) = unistd::tcsetpgrp(0, state.parent_pid) {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"error re-acquiring terminal: {}!", e
|
"error re-acquiring terminal: {}!", e
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this could be more elegant
|
|
||||||
if let Some(ref attr) = state.attr {
|
if let Some(ref attr) = state.attr {
|
||||||
tcsetattr(0, SetArg::TCSADRAIN, attr).ok();
|
tcsetattr(0, SetArg::TCSADRAIN, attr).ok();
|
||||||
} else {
|
} else {
|
||||||
panic!("somehow no attrs")
|
panic!("somehow no attrs")
|
||||||
}
|
}
|
||||||
|
|
||||||
state.last_exit_code = exit
|
state.last_exit_code = maybe
|
||||||
.code()
|
.code()
|
||||||
.unwrap_or(-1);
|
.unwrap_or(-1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
// sleep 1 sec
|
|
||||||
thread::sleep(Duration::from_millis(1000));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(format!("error waiting on child: {}", e))
|
return Err(format!("error waiting on child: {}", e))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue