fix(process): reap entire process group on cmd.Cancel (#39143)

Signed-off-by: Royce Remer <royceremer@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Royce Remer
2026-08-29 19:54:07 +00:00
committed by GitHub
co-authored by wxiaoguang
parent 88974d2db9
commit eea03676d3
21 changed files with 198 additions and 203 deletions
-23
View File
@@ -6,7 +6,6 @@ package process
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
@@ -87,25 +86,3 @@ func TestManager_Remove(t *testing.T) {
_, exists := pm.processMap[GetPID(p2Ctx)]
assert.False(t, exists, "PID %d is in the list but shouldn't", GetPID(p2Ctx))
}
func TestExecTimeoutNever(t *testing.T) {
// TODO Investigate how to improve the time elapsed per round.
maxLoops := 10
for i := 1; i < maxLoops; i++ {
_, stderr, err := GetManager().ExecTimeout(5*time.Second, "ExecTimeout", "git", "--version")
if err != nil {
t.Fatalf("git --version: %v(%s)", err, stderr)
}
}
}
func TestExecTimeoutAlways(t *testing.T) {
maxLoops := 100
for i := 1; i < maxLoops; i++ {
_, stderr, err := GetManager().ExecTimeout(100*time.Microsecond, "ExecTimeout", "sleep", "5")
// TODO Simplify logging and errors to get precise error type. E.g. checking "if err != context.DeadlineExceeded".
if err == nil {
t.Fatalf("sleep 5 secs: %v(%s)", err, stderr)
}
}
}