From 1028e31ae564dcfa7e2f9ab4df7e7602fd98b4c6 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 01:32:43 +0000 Subject: [PATCH] Fix process group signal escalation --- process.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/process.go b/process.go index 94ba6f5..2c153d8 100644 --- a/process.go +++ b/process.go @@ -251,7 +251,8 @@ func (p *Process) Signal(sig os.Signal) error { // Some shells briefly ignore or defer the signal while they are still // initialising child jobs. Retry a few times after short delays so the - // whole process group is more reliably terminated. + // whole process group is more reliably terminated. If the requested signal + // still does not stop the group, escalate to SIGKILL so callers do not hang. go func(pid int, sig syscall.Signal, done <-chan struct{}) { ticker := time.NewTicker(100 * time.Millisecond) defer ticker.Stop() @@ -264,6 +265,13 @@ func (p *Process) Signal(sig os.Signal) error { _ = syscall.Kill(-pid, sig) } } + + select { + case <-done: + return + default: + _ = syscall.Kill(-pid, syscall.SIGKILL) + } }(cmd.Process.Pid, sysSig, p.done) return nil