( pid: number, timeoutMs: number, deps: Pick<KillCommandDeps, 'pidAlive' | 'sleep' | 'now'>, )
| 97 | } |
| 98 | |
| 99 | async function waitForExit( |
| 100 | pid: number, |
| 101 | timeoutMs: number, |
| 102 | deps: Pick<KillCommandDeps, 'pidAlive' | 'sleep' | 'now'>, |
| 103 | ): Promise<boolean> { |
| 104 | const deadline = deps.now() + timeoutMs; |
| 105 | do { |
| 106 | if (!deps.pidAlive(pid)) return true; |
| 107 | await deps.sleep(POLL_INTERVAL_MS); |
| 108 | } while (deps.now() < deadline); |
| 109 | return !deps.pidAlive(pid); |
| 110 | } |
| 111 | |
| 112 | /** `process.kill(pid, 0)` probe — true if the pid exists, false on ESRCH. */ |
| 113 | export function pidAlive(pid: number): boolean { |
no test coverage detected