Skip to content

Commit b490a54

Browse files
shenghui kevinclaude
authored andcommitted
fix: handle SIGHUP/SIGTERM/SIGPIPE to prevent orphaned processes
When a controlling terminal is destroyed (SSH disconnect, tmux pane close), opencode processes become orphaned and continue running indefinitely because no signal handler triggers process.exit(). Add handlers for SIGHUP, SIGTERM, and SIGPIPE so the existing subprocess cleanup in the finally block runs promptly. Fixes anomalyco#14504 Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 206d81e commit b490a54

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎packages/opencode/src/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ process.on("uncaughtException", (e) => {
4545
})
4646
})
4747

48+
for (const sig of ["SIGHUP", "SIGTERM", "SIGPIPE"] as const) {
49+
process.on(sig, () => process.exit(1))
50+
}
51+
4852
const cli = yargs(hideBin(process.argv))
4953
.parserConfiguration({ "populate--": true })
5054
.scriptName("opencode")

0 commit comments

Comments
 (0)