fix(exec): kill child processes on agent shutdown + Linux PR_SET_PDEATHSIG helper (issue #24) - #39
Merged
Merged
Conversation
…THSIG helper (issue #24) - Wire killAllSpawnedProcesses() into stopAgent() so all remaining child processes are SIGKILL'd when the agent stops (SIGTERM/SIGINT). - Add process.on('exit') safety net for forced exits (uncaught exception). - Add optional prctl-pdeathsig Linux helper (bin/prctl-pdeathsig.c): when compiled and present in bin/, it wraps every spawned command so the kernel automatically sends SIGKILL to the child when the parent dies (PR_SET_PDEATHSIG). No-op on non-Linux platforms. - Helper is loaded at startup; if absent, commands spawn directly as before with no behavioral change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Old test asserted process.kill(-pid, 'SIGTERM') which was the previous
detached-process-tree approach. Current code uses child.kill('SIGTERM')
directly on the spawned child process. Update the assertion accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue #24 and #26 — detached subprocesses spawned by exec_run surviving parent process death.
Changes
src/index.ts
src/agent/tools/exec/runner.ts
src/agent/tools/exec/tests/runner.test.ts
bin/prctl-pdeathsig.c (new)
Behavior matrix
Closes #24
Closes #26
🤖 Generated with Claude Code