mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix(omp): sweep local agent PTYs during app quit (#21668)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user