From f6acf2e30e18ff41116d5a9772a3bfbbbbcba305 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 27 Dec 2025 14:34:06 +0100 Subject: [PATCH] processes() fix command line parsing (win) wip --- lib/processes.js | 102 +++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/lib/processes.js b/lib/processes.js index 390bcbc..618c2c2 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -949,59 +949,57 @@ function processes(callback) { processArray = JSON.parse(stdout); } catch {} processArray.forEach((element) => { - if (element.trim() !== '') { - const pid = element.ProcessId; - const parentPid = element.ParentProcessId; - const statusValue = element.ExecutionState || null; - const name = element.Caption; - const commandLine = element.CommandLine; - // get additional command line data - const commandPath = element.ExecutablePath; - const utime = element.UserModeTime; - const stime = element.KernelModeTime; - const memw = element.WorkingSetSize; - allcpuu = allcpuu + utime; - allcpus = allcpus + stime; - result.all++; - if (!statusValue) { - result.unknown++; - } - if (statusValue === '3') { - result.running++; - } - if (statusValue === '4' || statusValue === '5') { - result.blocked++; - } - - procStats.push({ - pid: pid, - utime: utime, - stime: stime, - cpu: 0, - cpuu: 0, - cpus: 0 - }); - procs.push({ - pid: pid, - parentPid: parentPid, - name: name, - cpu: 0, - cpuu: 0, - cpus: 0, - mem: (memw / os.totalmem()) * 100, - priority: element.Priority | null, - memVsz: element.PageFileUsage || null, - memRss: Math.floor((element.WorkingSetSize || 0) / 1024), - nice: 0, - started: element.CreationDate, - state: statusValue ? _winStatusValues[statusValue] : _winStatusValues[0], - tty: '', - user: '', - command: commandLine || name, - path: commandPath, - params: '' - }); + const pid = element.ProcessId; + const parentPid = element.ParentProcessId; + const statusValue = element.ExecutionState || null; + const name = element.Caption; + const commandLine = element.CommandLine; + // get additional command line data + const commandPath = element.ExecutablePath; + const utime = element.UserModeTime; + const stime = element.KernelModeTime; + const memw = element.WorkingSetSize; + allcpuu = allcpuu + utime; + allcpus = allcpus + stime; + result.all++; + if (!statusValue) { + result.unknown++; } + if (statusValue === '3') { + result.running++; + } + if (statusValue === '4' || statusValue === '5') { + result.blocked++; + } + + procStats.push({ + pid: pid, + utime: utime, + stime: stime, + cpu: 0, + cpuu: 0, + cpus: 0 + }); + procs.push({ + pid: pid, + parentPid: parentPid, + name: name, + cpu: 0, + cpuu: 0, + cpus: 0, + mem: (memw / os.totalmem()) * 100, + priority: element.Priority | null, + memVsz: element.PageFileUsage || null, + memRss: Math.floor((element.WorkingSetSize || 0) / 1024), + nice: 0, + started: element.CreationDate, + state: statusValue ? _winStatusValues[statusValue] : _winStatusValues[0], + tty: '', + user: '', + command: commandLine || name, + path: commandPath, + params: '' + }); }); result.sleeping = result.all - result.running - result.blocked - result.unknown;