MCPcopy Create free account
hub / github.com/EvoMap/evolver / listProcesses

Function listProcesses

src/ops/lifecycle.js:70–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68function _resetProcessTableForTest() { _processTableForTest = null; }
69
70function listProcesses() {
71 if (_processTableForTest) {
72 return _processTableForTest.map(function (p) { return { pid: p.pid, args: p.args }; });
73 }
74 if (process.platform === 'win32') {
75 var out = execFileText('powershell', [
76 '-NoProfile',
77 '-Command',
78 'Get-CimInstance Win32_Process | ForEach-Object { $cmd = if ($_.CommandLine) { $_.CommandLine } else { \'\'}; Write-Output (\'{0}\t{1}\' -f $_.ProcessId, $cmd) }'
79 ]);
80 var procs = [];
81 for (var line of out.split(/\r?\n/)) {
82 if (!line || !line.trim()) continue;
83 var tabIndex = line.indexOf('\t');
84 var pidText = tabIndex >= 0 ? line.slice(0, tabIndex).trim() : line.trim();
85 var cmdText = tabIndex >= 0 ? line.slice(tabIndex + 1).trim() : '';
86 var pid = parseInt(pidText, 10);
87 if (!isNaN(pid)) procs.push({ pid: pid, args: cmdText });
88 }
89 return procs;
90 }
91 var psOut = execText('ps -e -o pid=,args=');
92 var unixProcs = [];
93 for (var psLine of psOut.split('\n')) {
94 var trimmed = psLine.trim();
95 if (!trimmed) continue;
96 var parts = trimmed.split(/\s+/);
97 var pidUnix = parseInt(parts[0], 10);
98 if (isNaN(pidUnix)) continue;
99 unixProcs.push({ pid: pidUnix, args: parts.slice(1).join(' ') });
100 }
101 return unixProcs;
102}
103
104// --- Process Discovery ---
105

Callers 2

getRunningPidsFunction · 0.85
getCmdLineFunction · 0.85

Calls 2

execFileTextFunction · 0.85
execTextFunction · 0.85

Tested by

no test coverage detected