From 350c352989bc953d295dc884223038f3941c041c Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Fri, 30 Jan 2026 07:51:09 -0500 Subject: [PATCH] Safely kill processes --- src/cli.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 9aa94b8..a7ae65a 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -148,13 +148,21 @@ async function main() { process.stdin.resume(); if (pty) { // Resume child process first - process.kill(pty.pid, "SIGCONT"); + try { + process.kill(pty.pid, "SIGCONT"); + } catch { + // Child may have already exited + } // Give child time to wake up, then trigger redraw setTimeout(() => { if (pty && !isExiting) { const { cols, rows } = getTerminalSize(); pty.resize(cols, rows); - process.kill(pty.pid, "SIGWINCH"); // Tell child window changed + try { + process.kill(pty.pid, "SIGWINCH"); + } catch { + // Child may have already exited + } } }, 50); } @@ -187,7 +195,11 @@ async function main() { process.stdin.setRawMode(false); } if (pty) { - process.kill(pty.pid, "SIGTSTP"); + try { + process.kill(pty.pid, "SIGTSTP"); + } catch { + // Child may have already exited + } } process.kill(process.pid, "SIGTSTP"); return;