fix(subprocess): treat zombie-only groups as quiescent

This commit is contained in:
Tianyi Cui
2026-07-29 06:04:36 +08:00
parent ea75333c92
commit d29c73ddd6
4 changed files with 76 additions and 1 deletions

View File

@@ -268,6 +268,24 @@ describe('spawnSubprocess', () => {
expect(result.signal).toBe('SIGTERM')
})
it('does not wait for a Linux group that has only zombie members', async () => {
const pidFile = join(spillDir, `zombie-group-${Date.now()}.pid`)
let hasLiveMembers = false
const running = spawnSubprocess(spec(`sleep 60 & echo $! > ${pidFile}; echo leader-done`, { graceMs: 100 }), {
platform: 'linux',
linuxProcessGroupHasLiveMembers: () => hasLiveMembers,
})
const descendant = await waitForPidFile(pidFile)
try {
await running.done
await expect(running.waitForExit()).resolves.toBe(true)
} finally {
hasLiveMembers = true
running.terminate()
await waitGone(descendant)
}
})
it('bounds inherited-pipe draining after the shell exits', async () => {
const pidFile = join(spillDir, `pipe-holder-${Date.now()}.pid`)
const started = Date.now()