Skip to content

Commit 68dd866

Browse files
committed
fix: check process group instead of parent PID in terminate
kill -0 ${pid} only checks if the parent is alive, but children may survive SIGTERM. Changed to kill -0 ${negPid} to check if any process in the group is still alive before deciding to send SIGKILL.
1 parent 384ff92 commit 68dd866

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/node/runtime/backgroundCommands.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe("backgroundCommands", () => {
133133

134134
expect(result).toContain("kill -15 -1234 2>/dev/null || true");
135135
expect(result).toContain("sleep 2");
136-
expect(result).toContain("kill -0 1234");
136+
expect(result).toContain("kill -0 -1234");
137137
expect(result).toContain("kill -9 -1234 2>/dev/null || true");
138138
expect(result).toContain("echo 137 >"); // SIGKILL exit code
139139
expect(result).toContain("echo 143 >"); // SIGTERM exit code (written after process exits)

src/node/runtime/backgroundCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function buildTerminateCommand(
139139
return (
140140
`kill -15 ${negPid} 2>/dev/null || true; ` +
141141
`sleep 2; ` +
142-
`if kill -0 ${pid} 2>/dev/null; then ` +
142+
`if kill -0 ${negPid} 2>/dev/null; then ` +
143143
`kill -9 ${negPid} 2>/dev/null || true; ` +
144144
`echo ${EXIT_CODE_SIGKILL} > ${quotePath(exitCodePath)}; ` +
145145
`else ` +

0 commit comments

Comments
 (0)