Преглед на файлове

fix(core): handle SIGHUP and kill process (#16057)

James Long преди 1 месец
родител
ревизия
45ac20b8aa
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      packages/opencode/src/index.ts

+ 5 - 0
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")