Safely kill processes
This commit is contained in:
parent
364e3d909e
commit
350c352989
1 changed files with 15 additions and 3 deletions
14
src/cli.ts
14
src/cli.ts
|
|
@ -148,13 +148,21 @@ async function main() {
|
|||
process.stdin.resume();
|
||||
if (pty) {
|
||||
// Resume child process first
|
||||
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) {
|
||||
try {
|
||||
process.kill(pty.pid, "SIGTSTP");
|
||||
} catch {
|
||||
// Child may have already exited
|
||||
}
|
||||
}
|
||||
process.kill(process.pid, "SIGTSTP");
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue