From ef45246ea06e1c7f43d4cfb9aed6b7a209eb11e0 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Wed, 1 Apr 2026 23:46:33 +0300 Subject: [PATCH] fix(sat): kill entire process group on task cancel exec.CommandContext only kills the direct child (the shell script), leaving grandchildren (john, gpu-burn, etc.) as orphans. Set Setpgid so each SAT job runs in its own process group, then send SIGKILL to the whole group (-pgid) in the Cancel hook. Co-Authored-By: Claude Sonnet 4.6 --- audit/internal/platform/sat.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/audit/internal/platform/sat.go b/audit/internal/platform/sat.go index 13773a3..986b7f5 100644 --- a/audit/internal/platform/sat.go +++ b/audit/internal/platform/sat.go @@ -12,6 +12,7 @@ import ( "os" "os/exec" "path/filepath" + "syscall" "sort" "strconv" "strings" @@ -531,6 +532,13 @@ func runSATCommandCtx(ctx context.Context, verboseLog, name string, cmd []string } c := exec.CommandContext(ctx, resolvedCmd[0], resolvedCmd[1:]...) + c.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} + c.Cancel = func() error { + if c.Process != nil { + _ = syscall.Kill(-c.Process.Pid, syscall.SIGKILL) + } + return nil + } if len(env) > 0 { c.Env = append(os.Environ(), env...) }