diff --git a/packages/opencode/src/cli/cmd/tui/context/exit.tsx b/packages/opencode/src/cli/cmd/tui/context/exit.tsx index 3ed4ae3d2c..236320cf06 100644 --- a/packages/opencode/src/cli/cmd/tui/context/exit.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/exit.tsx @@ -53,6 +53,7 @@ export const { use: useExit, provider: ExitProvider } = createSimpleContext({ message: store, }, ) + process.on("SIGHUP", () => exit()) return exit }, }) diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index fe7fd63ef1..b3d1db7eb0 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -47,11 +47,6 @@ 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")