Skip to content

Commit 258518e

Browse files
fix(server): Claude stdin observer exits with its child's signal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0e987b4 commit 258518e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎apps/server/src/provider/testFixtures/ClaudeStdin.fixture.mjs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ process.stdin.on("end", () => {
6060
child.stdin.end();
6161
record(decoder.end() + "\n");
6262
});
63-
child.on("exit", (code) => process.exit(code ?? 1));
64-
process.on("SIGTERM", () => child.kill("SIGTERM"));
65-
process.on("SIGINT", () => child.kill("SIGINT"));
63+
const forward = (signal) => child.kill(signal);
64+
process.on("SIGTERM", forward);
65+
process.on("SIGINT", forward);
66+
child.on("exit", (code, signal) => {
67+
if (code !== null) process.exit(code);
68+
// Mirror the child's signal death; drop our forwarders first so the self-signal is not caught.
69+
process.off("SIGTERM", forward);
70+
process.off("SIGINT", forward);
71+
process.kill(process.pid, signal);
72+
// Node ignores some signals (SIGPIPE), so still exit if the self-signal did not end us.
73+
process.exit(1);
74+
});

0 commit comments

Comments
 (0)