(pid: number)
| 38 | |
| 39 | /** Check if a PID is alive. Pure boolean probe — returns false for ALL errors. */ |
| 40 | export function isProcessAlive(pid: number): boolean { |
| 41 | if (IS_WINDOWS) { |
| 42 | try { |
| 43 | const result = Bun.spawnSync( |
| 44 | ['tasklist', '/FI', `PID eq ${pid}`, '/NH', '/FO', 'CSV'], |
| 45 | { stdout: 'pipe', stderr: 'pipe', timeout: 3000 } |
| 46 | ); |
| 47 | return result.stdout.toString().includes(`"${pid}"`); |
| 48 | } catch { |
| 49 | return false; |
| 50 | } |
| 51 | } |
| 52 | try { |
| 53 | process.kill(pid, 0); |
| 54 | return true; |
| 55 | } catch { |
| 56 | return false; |
| 57 | } |
| 58 | } |
no outgoing calls
no test coverage detected