|
6 | 6 | type ExecBackgroundResult, |
7 | 7 | } from '../../utils/exec.ts'; |
8 | 8 | import { withKeyedLock } from '../../utils/keyed-lock.ts'; |
9 | | -import { isProcessAlive } from '../../utils/process-identity.ts'; |
| 9 | +import { isProcessAlive, isProcessGroupAlive } from '../../utils/process-identity.ts'; |
10 | 10 | import type { DeviceInfo } from '../../utils/device.ts'; |
11 | 11 | import { buildSimctlArgsForDevice } from './simctl.ts'; |
12 | 12 | import { |
@@ -192,7 +192,9 @@ async function stopRunnerSessionInternal( |
192 | 192 | new Promise<void>((resolve) => setTimeout(resolve, RUNNER_STOP_WAIT_TIMEOUT_MS)), |
193 | 193 | ]); |
194 | 194 | } catch {} |
195 | | - await killRunnerProcessTree(session.child.pid, 'SIGKILL'); |
| 195 | + if (isRunnerProcessTreeAlive(session.child.pid)) { |
| 196 | + await killRunnerProcessTree(session.child.pid, 'SIGKILL'); |
| 197 | + } |
196 | 198 | cleanupTempFile(session.xctestrunPath); |
197 | 199 | cleanupTempFile(session.jsonPath); |
198 | 200 | await session.simulatorSetRedirect?.release(); |
@@ -274,6 +276,11 @@ function isRunnerProcessAlive(pid: number | undefined): boolean { |
274 | 276 | return isProcessAlive(pid); |
275 | 277 | } |
276 | 278 |
|
| 279 | +function isRunnerProcessTreeAlive(pid: number | undefined): boolean { |
| 280 | + if (!pid) return false; |
| 281 | + return isRunnerProcessAlive(pid) || isProcessGroupAlive(pid); |
| 282 | +} |
| 283 | + |
277 | 284 | async function killRunnerProcessTree( |
278 | 285 | pid: number | undefined, |
279 | 286 | signal: 'SIGINT' | 'SIGTERM' | 'SIGKILL', |
|
0 commit comments