openclaw/src/shared/pid-alive.ts

12 lines
203 B
TypeScript

export function isPidAlive(pid: number): boolean {
if (!Number.isFinite(pid) || pid <= 0) {
return false;
}
try {
process.kill(pid, 0);
return true;
} catch {
return false;
}
}