dont spin at max speed when waiting for foreground process
Signed-off-by: Ava Hahn <ava@sunnypup.io>
This commit is contained in:
parent
e042cd1152
commit
5dcf601384
2 changed files with 7 additions and 5 deletions
|
|
@ -50,6 +50,8 @@ use {
|
|||
env::set_current_dir,
|
||||
os::unix::process::CommandExt,
|
||||
mem,
|
||||
thread,
|
||||
time::Duration,
|
||||
},
|
||||
nix::{
|
||||
unistd, unistd::Pid,
|
||||
|
|
@ -216,7 +218,7 @@ fn launch_command(
|
|||
}
|
||||
|
||||
// the analogous make_background happens in the app when the user sends it the corresponding signal
|
||||
fn make_foreground(pid: u32, state: &mut ShellState) -> Result<(), String>{
|
||||
fn make_foreground(pid: u32, state: &mut ShellState) -> Result<(), String> {
|
||||
for i in &mut state.children {
|
||||
if i.id() == pid {
|
||||
let pid_fancy = Pid::from_raw(pid as i32);
|
||||
|
|
@ -253,6 +255,9 @@ fn make_foreground(pid: u32, state: &mut ShellState) -> Result<(), String>{
|
|||
.unwrap_or(-1);
|
||||
|
||||
break;
|
||||
} else {
|
||||
// sleep 1 sec
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue