(pid: number, killCheck: (pid: number, signal: number) => void = process.kill)
| 64 | } |
| 65 | |
| 66 | export function isProcessAlive(pid: number, killCheck: (pid: number, signal: number) => void = process.kill): boolean { |
| 67 | if (!Number.isFinite(pid) || pid <= 0) return false; |
| 68 | |
| 69 | try { |
| 70 | killCheck(pid, 0); |
| 71 | return true; |
| 72 | } catch (error) { |
| 73 | if (!error || typeof error !== "object") return false; |
| 74 | const { code } = error as ErrorWithCode; |
| 75 | return code !== "ESRCH"; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | export function createIdleMonitor(options: IdleMonitorOptions): IdleMonitor { |
| 80 | if (options.timeoutMs <= 0) { |
no outgoing calls
no test coverage detected