Skip to content

Commit

Permalink
Fix processLister.stdout undefined. Closes indexzero#21
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Jan 31, 2022
1 parent 2b6476c commit 17f51a9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ module.exports = function childrenOfPid(pid, callback) {
// smss.exe 4 228
// ```

var cmd;
var processLister;

if (process.platform === 'win32') {
// See also: https://github.com/nodejs/node-v0.x-archive/issues/2318
processLister = spawn('wmic.exe', ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']);
cmd = 'wmix.exe';
processLister = spawn(cmd, ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']);
} else {
processLister = spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']);
cmd = 'ps';
processLister = spawn(cmd, ['-A', '-o', 'ppid,pid,stat,comm']);
}

if (!processLister.stdout) {
return cb(new Error('Unable to spawn "' + cmd + '"'));
}

es.connect(
Expand Down

0 comments on commit 17f51a9

Please sign in to comment.