1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

avoid sending twice same signal to child process

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

View file

@ -202,14 +202,15 @@ 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),
_ = process.send_signal_group(signal); false => {
let kill_signal = signal_by_name_or_value("KILL").unwrap(); _ = process.send_signal_group(signal);
let continued_signal = signal_by_name_or_value("CONT").unwrap(); let kill_signal = signal_by_name_or_value("KILL").unwrap();
if signal != kill_signal && signal != continued_signal { let continued_signal = signal_by_name_or_value("CONT").unwrap();
_ = process.send_signal(continued_signal); if signal != kill_signal && signal != continued_signal {
_ = process.send_signal_group(continued_signal); _ = process.send_signal_group(continued_signal);
}
} }
} }
} }