diff --git a/packages/subprocess/subprocess-local/src/runner-launch.ts b/packages/subprocess/subprocess-local/src/runner-launch.ts index 95d091d3fe..e83dca6eaa 100644 --- a/packages/subprocess/subprocess-local/src/runner-launch.ts +++ b/packages/subprocess/subprocess-local/src/runner-launch.ts @@ -68,6 +68,7 @@ interface RunnerHandshake { function runnerExited(child: ChildProcess): boolean { if (child.exitCode !== null || child.signalCode !== null) return true if (child.pid === undefined) return true + /* v8 ignore start -- Linux zombie detection is exercised by the real user-systemd test environment. */ if (process.platform === 'linux') { try { const stat = readFileSync(`/proc/${String(child.pid)}/stat`, 'utf8') @@ -77,10 +78,12 @@ function runnerExited(child: ChildProcess): boolean { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return true } } + /* v8 ignore stop */ try { process.kill(child.pid, 0) return false } catch (error) { + /* v8 ignore next -- EPERM means the known process still exists but is not signalable. */ return (error as NodeJS.ErrnoException).code === 'ESRCH' } } diff --git a/packages/subprocess/subprocess-local/tests/spawn-runner.spec.ts b/packages/subprocess/subprocess-local/tests/spawn-runner.spec.ts index 2c4d323f76..7cd0baa027 100644 --- a/packages/subprocess/subprocess-local/tests/spawn-runner.spec.ts +++ b/packages/subprocess/subprocess-local/tests/spawn-runner.spec.ts @@ -1,6 +1,7 @@ import { spawnSync } from 'node:child_process' import type { ChildProcess } from 'node:child_process' import { existsSync, statSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' import { fileURLToPath } from 'node:url' import { describe, expect, it, vi } from 'vitest' import type { SubprocessSpawnSpec } from '@deepseek-ai/dsh-subprocess' @@ -131,6 +132,7 @@ describe('spawn runner transport', () => { const files = createRunnerFiles({ argv: ['node'], cwd: '.', env: {} }) try { expect(readRunnerEvents(files.eventsPath)).toEqual([]) + await expect(readRunnerEventsAsync(join(files.directory, 'missing.ndjson'))).resolves.toEqual([]) appendRunnerEvent(files.eventsPath, { type: 'started', pid: 123 }) appendRunnerEvent(files.eventsPath, { type: 'runner-error',