mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
avoid sending twice same signal to child process
This commit is contained in:
parent
1725479c06
commit
abfd000367
1 changed files with 9 additions and 8 deletions
|
@ -202,17 +202,18 @@ fn send_signal(process: &mut Child, signal: usize, foreground: bool) {
|
||||||
// NOTE: GNU timeout doesn't check for errors of signal.
|
// NOTE: GNU timeout doesn't check for errors of signal.
|
||||||
// The subprocess might have exited just after the timeout.
|
// The subprocess might have exited just after the timeout.
|
||||||
// Sending a signal now would return "No such process", but we should still try to kill the children.
|
// Sending a signal now would return "No such process", but we should still try to kill the children.
|
||||||
_ = process.send_signal(signal);
|
match foreground {
|
||||||
if !foreground {
|
true => _ = process.send_signal(signal),
|
||||||
|
false => {
|
||||||
_ = process.send_signal_group(signal);
|
_ = process.send_signal_group(signal);
|
||||||
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
||||||
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
||||||
if signal != kill_signal && signal != continued_signal {
|
if signal != kill_signal && signal != continued_signal {
|
||||||
_ = process.send_signal(continued_signal);
|
|
||||||
_ = process.send_signal_group(continued_signal);
|
_ = process.send_signal_group(continued_signal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Wait for a child process and send a kill signal if it does not terminate.
|
/// Wait for a child process and send a kill signal if it does not terminate.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue