()
| 104 | // --- Process Discovery --- |
| 105 | |
| 106 | function getRunningPids() { |
| 107 | try { |
| 108 | var pids = []; |
| 109 | for (var proc of listProcesses()) { |
| 110 | var pid = proc.pid; |
| 111 | var cmd = (proc.args || '').trim(); |
| 112 | if (pid === process.pid) continue; |
| 113 | var cmdLower = cmd.toLowerCase(); |
| 114 | // Match any `node ... index.js ... --loop` invocation. |
| 115 | // Wrapper path prefix filters were removed so launchd/plist or direct |
| 116 | // node invocations are also discovered (fixes #379, #403). |
| 117 | if (cmdLower.includes('node') && cmdLower.includes('index.js') && cmdLower.includes('--loop')) { |
| 118 | pids.push(pid); |
| 119 | } |
| 120 | } |
| 121 | return [...new Set(pids)].filter(isPidRunning); |
| 122 | } catch (e) { |
| 123 | return []; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | function isPidRunning(pid) { |
| 128 | if (_processTableForTest) { |
no test coverage detected