| 29 | } |
| 30 | |
| 31 | export function readProcessStartTime(pid: number): string | null { |
| 32 | if (!Number.isInteger(pid) || pid <= 0) return null; |
| 33 | try { |
| 34 | const result = runCmdSync('ps', ['-p', String(pid), '-o', 'lstart='], { |
| 35 | allowFailure: true, |
| 36 | timeoutMs: PS_TIMEOUT_MS, |
| 37 | }); |
| 38 | if (result.exitCode !== 0) return null; |
| 39 | const value = result.stdout.trim(); |
| 40 | return value.length > 0 ? value : null; |
| 41 | } catch { |
| 42 | return null; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export function readProcessCommand(pid: number): string | null { |
| 47 | if (!Number.isInteger(pid) || pid <= 0) return null; |