summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/opencode/src/index.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts
index 35b42dce7..4fd5f0e67 100644
--- a/packages/opencode/src/index.ts
+++ b/packages/opencode/src/index.ts
@@ -46,6 +46,11 @@ process.on("uncaughtException", (e) => {
})
})
+// Ensure the process exits on terminal hangup (eg. closing the terminal tab).
+// Without this, long-running commands like `serve` block on a never-resolving
+// promise and survive as orphaned processes.
+process.on("SIGHUP", () => process.exit())
+
let cli = yargs(hideBin(process.argv))
.parserConfiguration({ "populate--": true })
.scriptName("opencode")