Skip to content

Commit b3f92e1

Browse files
committed
test(utils): stop bash tail-exec flaking the SIGTERM-ignored terminate test
bash -c "trap \"\" TERM; sleep 60" tail-execs into sleep, so /proc/pid/cmdline argv0 becomes "sleep". TerminateProcess verifies argv0 == "bash" before signaling; when the exec wins the startup race against that check it no-ops, the undead sleep runs its full 60s, and the utils package trips its 120s test timeout. A trailing "; :" keeps bash resident so the cmdline stays "bash".
1 parent 7e4406f commit b3f92e1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

utils/process_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ func TestTerminateProcess_InvalidPID(t *testing.T) {
210210
}
211211

212212
func TestTerminateProcess_SIGTERMIgnored_FallsBackToKill(t *testing.T) {
213-
// Process that traps SIGTERM: won't die from SIGTERM alone.
214-
cmd := exec.Command("bash", "-c", `trap "" TERM; sleep 60`)
213+
// Traps SIGTERM so only SIGKILL can end it. The trailing "; :" stops bash from
214+
// tail-exec'ing into sleep, which would rename argv0 and fail the "bash" cmdline check.
215+
cmd := exec.Command("bash", "-c", `trap "" TERM; sleep 60; :`)
215216
if err := cmd.Start(); err != nil {
216217
t.Fatalf("start: %v", err)
217218
}

0 commit comments

Comments
 (0)