Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): normalize a numeric kill signal to its name before stamping

Adam Eivya32f629f8e92
diff --git a/server/lib/detachedSpawn.js b/server/lib/detachedSpawn.js
index 0dd9f511f4..56f8c4cbcf 100644
--- a/server/lib/detachedSpawn.js
+++ b/server/lib/detachedSpawn.js
@@ -296,7 +296,12 @@ export async function spawnDetached(bin, args = [], {
// Signal 0 is an existence PROBE, not a kill — hand it to Node so callers
// keep that meaning instead of force-killing the tree.
if (signal === 0 || signal === '0') return nativeKill(signal);
- killSignal = signal;
+ // `kill()` also accepts a signal NUMBER, but ChildProcess reports signal
+ // NAMES on close — stamping the raw number would break every
+ // `signal === 'SIGKILL'` comparison. Reuse the same inverted table the
+ // POSIX handle decodes `wait` statuses with; an unrecognized number
+ // stamps nothing and leaves Node's own reporting alone.
+ killSignal = typeof signal === 'number' ? (SIGNAL_BY_NUMBER[signal] ?? null) : signal;
child.killed = true;
killProcessTree(treeKillTarget, signal, { processGroup: true });
return true;
diff --git a/server/lib/detachedSpawn.test.js b/server/lib/detachedSpawn.test.js
index b85d76e016..0467e10123 100644
--- a/server/lib/detachedSpawn.test.js
+++ b/server/lib/detachedSpawn.test.js
@@ -312,6 +312,24 @@ describe('spawnDetached', () => {
}
});
+ it('win32 fallback stamps a numeric signal as its NAME on close', async () => {
+ const restorePlatform = pinPlatform('win32');
+ try {
+ const { handle, terminate } = await spawnWin32Fallback();
+ const closed = onClose(handle);
+ // kill() accepts a number; ChildProcess reports names, so a raw 9 would
+ // break every `signal === 'SIGKILL'` comparison downstream.
+ handle.kill(9);
+ await terminate();
+ const { code, signal } = await closed;
+ expect(code).toBeNull();
+ expect(signal).toBe('SIGKILL');
+ expect(handle.signalCode).toBe('SIGKILL');
+ } finally {
+ restorePlatform();
+ }
+ });
+
it('win32 fallback refuses to tree-kill a child that already exited', async () => {
const restorePlatform = pinPlatform('win32');
try {