Skip to content

Commit f670d83

Browse files
committed
Force-kill orphaned PHP processes in e2e session cleanup
1 parent 89e8c53 commit f670d83

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

apps/studio/e2e/e2e-helpers.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawnSync } from 'child_process';
12
import { randomUUID } from 'crypto';
23
import { tmpdir } from 'os';
34
import path from 'path';
@@ -84,6 +85,22 @@ export class E2ESession {
8485
console.log( 'Process exit timeout' );
8586
} finally {
8687
this.stopCapturingMainProcessLogs();
88+
this.killOrphanedSessionProcesses();
89+
}
90+
}
91+
92+
// Native PHP sites spawn `php -S` subprocesses. When the daemon (or its children) is SIGKILL'd
93+
// during shutdown, those PHP processes get reparented to init and keep running, holding file
94+
// handles in the session temp dir open and blocking the worker teardown. Force-kill anything
95+
// still referencing this session's path.
96+
private killOrphanedSessionProcesses(): void {
97+
if ( process.platform === 'win32' ) {
98+
return; // pkill not available; rely on Windows job-object behavior elsewhere.
99+
}
100+
try {
101+
spawnSync( 'pkill', [ '-9', '-f', this.sessionPath ], { stdio: 'ignore' } );
102+
} catch {
103+
// Best effort — failure to clean up shouldn't block the test run.
87104
}
88105
}
89106

0 commit comments

Comments
 (0)