mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37: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,14 +202,15 @@ fn send_signal(process: &mut Child, signal: usize, foreground: bool) {
|
|||
// NOTE: GNU timeout doesn't check for errors of signal.
|
||||
// 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.
|
||||
_ = process.send_signal(signal);
|
||||
if !foreground {
|
||||
_ = process.send_signal_group(signal);
|
||||
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
||||
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
||||
if signal != kill_signal && signal != continued_signal {
|
||||
_ = process.send_signal(continued_signal);
|
||||
_ = process.send_signal_group(continued_signal);
|
||||
match foreground {
|
||||
true => _ = process.send_signal(signal),
|
||||
false => {
|
||||
_ = process.send_signal_group(signal);
|
||||
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
||||
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
||||
if signal != kill_signal && signal != continued_signal {
|
||||
_ = process.send_signal_group(continued_signal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue