| 22 | let lastError: string | undefined; |
| 23 | |
| 24 | const parseLine = (line: string): ProcessTreeEntry | null => { |
| 25 | const tokens = line.trim().split(/\s+/); |
| 26 | if (tokens.length < 3) { |
| 27 | return null; |
| 28 | } |
| 29 | const pid = tokens[0]; |
| 30 | const ppid = tokens[1]; |
| 31 | const name = tokens[2]; |
| 32 | if (!pid || !ppid || !name) { |
| 33 | return null; |
| 34 | } |
| 35 | const command = tokens.slice(3).join(' '); |
| 36 | return { pid, ppid, name, command }; |
| 37 | }; |
| 38 | |
| 39 | const fetchProcessInfo = async (pid: string): Promise<ProcessTreeEntry | null> => { |
| 40 | const command = ['-o', 'pid=,ppid=,comm=,args=', '-p', pid]; |