Skip to content

Commit 0c6b78b

Browse files
authored
Merge pull request #286 from dcantah/cleanup-procs
Cgroup2: Cleanup procs in TestKill
2 parents 0218f40 + bfa81d2 commit 0c6b78b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cgroup2/manager_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"os/exec"
23+
"syscall"
2324
"testing"
2425
"time"
2526

@@ -147,9 +148,13 @@ func TestKill(t *testing.T) {
147148
)
148149
for i := 0; i < numProcs; i++ {
149150
cmd := exec.Command("sleep", "infinity")
151+
// Don't leak the process if we fail to join the cg,
152+
// send sigkill after tests over.
153+
cmd.SysProcAttr = &syscall.SysProcAttr{
154+
Pdeathsig: syscall.SIGKILL,
155+
}
150156
err = cmd.Start()
151157
require.NoError(t, err)
152-
require.NotNil(t, cmd.Process, "process is nil")
153158

154159
err = manager.AddProc(uint64(cmd.Process.Pid))
155160
require.NoError(t, err)

0 commit comments

Comments
 (0)