Pages

Tuesday, August 22, 2017

how to Iterate list of running processes in NodeJS

how to Iterate list of running processes in NodeJS

We can iterate the list of running PIDs in a system from NodeJS Module called "current-process"

URL of the NodeJS Module: https://github.com/branneman/current-processes

See the sample code below.

var  cps= require('current-processes');
cps.get(function(err,o){
    Object.keys(o).forEach(function(key) {
                 var val = o[key];
                 console.log( "%s " , val.name "- %d ", val.pid);
    });

 });


This will print the name and ID of the Process.

No comments:

Post a Comment