| 89 | } |
| 90 | |
| 91 | function describeLinuxProcess(pid: number): ProcessDescription { |
| 92 | let commandLine: string | null = null; |
| 93 | let name: string | null = null; |
| 94 | try { |
| 95 | const args = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8').split('\0').filter(Boolean); |
| 96 | if (args.length > 0) commandLine = args.join(' '); |
| 97 | } catch { /* gone, or hidden (hidepid) */ } |
| 98 | try { |
| 99 | name = fs.readFileSync(`/proc/${pid}/comm`, 'utf8').trim() || null; |
| 100 | } catch { /* gone, or hidden */ } |
| 101 | return { name, commandLine }; |
| 102 | } |
| 103 | |
| 104 | async function describePsProcess(pid: number): Promise<ProcessDescription> { |
| 105 | const [args, comm] = await Promise.all([ |