Read PID from the PID file. Returns the PID number or null.
()
| 427 | |
| 428 | /** Read PID from the PID file. Returns the PID number or null. */ |
| 429 | function readPid() { |
| 430 | try { |
| 431 | const content = readFileSync(PID_FILE, 'utf8').trim(); |
| 432 | const pid = Number(content); |
| 433 | return Number.isFinite(pid) && pid > 0 ? pid : null; |
| 434 | } catch { |
| 435 | return null; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | /** Check whether a process with the given PID is still running. */ |
| 440 | function isProcessAlive(pid) { |