mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 21:47:46 +00:00
Use ChildExt to wait from timeout.rs
This commit is contained in:
parent
dc40480e6e
commit
0691965d63
1 changed files with 14 additions and 12 deletions
|
@ -128,31 +128,33 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
process.set_timeout(Some((duration * 1000f64) as u64)); // FIXME: this ignores the f64...
|
match process.wait_or_timeout(duration) {
|
||||||
match process.wait() {
|
Ok(Some(status)) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
||||||
Ok(status) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
Ok(None) => {
|
||||||
Err(_) => {
|
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.send_signal(signal));
|
return_if_err!(ERR_EXIT_STATUS, process.send_signal(signal));
|
||||||
process.set_timeout(Some((kill_after * 1000f64) as u64));
|
match process.wait_or_timeout(kill_after) {
|
||||||
match process.wait() {
|
Ok(Some(status)) => {
|
||||||
Ok(status) => {
|
|
||||||
if preserve_status {
|
if preserve_status {
|
||||||
status.code().unwrap_or_else(|| status.signal().unwrap())
|
status.code().unwrap_or_else(|| status.signal().unwrap())
|
||||||
} else {
|
} else {
|
||||||
124
|
124
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
Err(_) => {
|
Ok(None) => {
|
||||||
if kill_after == 0f64 {
|
if kill_after == 0f64 {
|
||||||
// XXX: this may not be right
|
// XXX: this may not be right
|
||||||
return 124;
|
return 124;
|
||||||
}
|
}
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.send_signal(signals::signal_by_name_or_value("KILL").unwrap()));
|
return_if_err!(ERR_EXIT_STATUS, process.send_signal(signals::signal_by_name_or_value("KILL").unwrap()));
|
||||||
process.set_timeout(None);
|
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.wait());
|
return_if_err!(ERR_EXIT_STATUS, process.wait());
|
||||||
137
|
137
|
||||||
}
|
},
|
||||||
|
Err(_) => return 124,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
Err(_) => {
|
||||||
|
return_if_err!(ERR_EXIT_STATUS, process.send_signal(signal));
|
||||||
|
ERR_EXIT_STATUS
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue