1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

wait for child to stop after sending signal

This commit is contained in:
Ulrich Hornung 2024-03-12 19:04:46 +01:00
parent abfd000367
commit 38b15c9736
No known key found for this signature in database
GPG key ID: 64EA3BAAF1BC0603

View file

@ -343,8 +343,15 @@ fn timeout(
send_signal(process, signal, foreground);
match kill_after {
None => {
let status = process.wait()?;
if preserve_status {
Err(ExitStatus::SignalSent(signal).into())
if let Some(ec) = status.code() {
Err(ec.into())
} else if let Some(sc) = status.signal() {
Err(ExitStatus::SignalSent(sc.try_into().unwrap()).into())
} else {
Err(ExitStatus::CommandTimedOut.into())
}
} else {
Err(ExitStatus::CommandTimedOut.into())
}