Skip to content

Commit 8f4eec4

Browse files
siimveneclaude
andcommitted
Deliver a real force-kill when the app-server close deadline fires
terminateProcessTree was a verified no-op here on POSIX: the child is not detached, so the process-group signal hits ESRCH and nothing falls back to the pid, and the signal was only SIGTERM regardless (which the wedged child ignores by hypothesis). The deadline now sends SIGKILL to the child pid on POSIX (empirically verified against a SIGTERM-immune child) and keeps taskkill /T /F on Windows where the child is a cmd.exe wrapper needing a tree kill. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 0fb97bb commit 8f4eec4

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎plugins/codex/scripts/app-server-broker.mjs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,22 @@ async function main() {
193193
// so a child that ignores it would wedge this shutdown indefinitely
194194
// (record already cleared, session dir still present, both processes
195195
// alive while the next command spawns a replacement). After the deadline,
196-
// force-kill the child's tree; its exit settles the dangling close.
196+
// deliver a real force-kill; the child's exit settles the dangling close.
197+
// On POSIX that must be SIGKILL to the pid itself: the child is not
198+
// detached, so a process-group signal (kill(-pid)) hits ESRCH and
199+
// terminateProcessTree delivers nothing there. On Windows the child is a
200+
// cmd.exe wrapper, so the taskkill /T /F tree kill is the right tool.
197201
await Promise.race([
198202
appClient.close().catch(() => {}),
199203
new Promise((resolve) => {
200204
const timer = setTimeout(() => {
201205
try {
202-
if (appClient.proc?.pid) {
203-
terminateProcessTree(appClient.proc.pid);
206+
if (appClient.proc && appClient.proc.exitCode === null) {
207+
if (process.platform === "win32") {
208+
terminateProcessTree(appClient.proc.pid);
209+
} else {
210+
appClient.proc.kill("SIGKILL");
211+
}
204212
}
205213
} catch {
206214
// Best effort; the whole-shutdown backstop above still applies.

0 commit comments

Comments
 (0)