GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: add SIGHUP/SIGTERM/SIGPIPE handlers to prevent orphaned processes · coleleavitt/opencode@76ee4ab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/src
    • index.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/index.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/index.ts
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ process.on("uncaughtException", (e) => {
4545
})
4646
})
4747

48+
// Handle terminal death signals to prevent orphaned processes.
49+
// When a controlling terminal is destroyed (SSH disconnect, tmux pane close, etc.),
50+
// the kernel sends SIGHUP. Without this handler, the process continues running
51+
// indefinitely because the TUI event loop blocks on stdin that will never arrive,
52+
// preventing the `process.exit()` in the finally block from ever executing.
53+
// This was observed to leak ~4.7 GB per orphaned instance.
54+
for (const sig of ["SIGHUP", "SIGTERM", "SIGPIPE"] as const) {
55+
process.on(sig, () => {
56+
process.exit(1)
57+
})
58+
}
59+
4860
const cli = yargs(hideBin(process.argv))
4961
.parserConfiguration({ "populate--": true })
5062
.scriptName("opencode")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.