(pid: number, timeoutMs: number)
| 87 | } |
| 88 | |
| 89 | export async function waitForProcessExit(pid: number, timeoutMs: number): Promise<boolean> { |
| 90 | if (!isProcessAlive(pid)) return true; |
| 91 | const start = Date.now(); |
| 92 | while (Date.now() - start < timeoutMs) { |
| 93 | await sleep(50); |
| 94 | if (!isProcessAlive(pid)) return true; |
| 95 | } |
| 96 | return !isProcessAlive(pid); |
| 97 | } |
| 98 | |
| 99 | export async function stopProcessForTakeover( |
| 100 | pid: number, |