fix(omp): sweep local agent PTYs during app quit (#21668)

This commit is contained in:
Neil
2026-09-19 05:48:32 -07:00
committed by GitHub
parent 0e90e855db
commit 2e278426ef
2 changed files with 21 additions and 1 deletions
@@ -566,6 +566,20 @@ describe('LocalPtyProvider', () => {
expect(list).toHaveLength(0)
})
it('force-kills an OMP PTY root during app quit', async () => {
const killSpy = vi.fn()
spawnMock.mockReturnValue({
...mockProc,
kill: killSpy
})
await provider.spawn({ cols: 80, rows: 24, launchAgent: 'omp' })
provider.killAll()
expect(killSpy).toHaveBeenCalledWith('SIGKILL')
})
it('does not destroy after intentional Windows orphan kills', async () => {
Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' })
const destroySpy = vi.fn()
+7 -1
View File
@@ -243,7 +243,13 @@ export function killAllLocalPtys(): void {
disposePtyExitListener(id)
if (!(process.platform === 'win32' && ptyTerminationMode.has(id))) {
try {
proc.kill()
if (ptyAgentSessionIds.has(id) && process.platform !== 'win32') {
// App quit is synchronous, so sweep attached agent process groups before
// releasing node-pty; otherwise OMP workers can outlive the foreground PTY.
forceKillPosixPtyProcessGroups(proc.pid, () => proc.kill('SIGKILL'))
} else {
proc.kill()
}
} catch {
/* Process may already be dead. */
}