0
I would like to know how to take all processes with the nodejs equal to the c#
Process[] processlist = Process.GetProcesses();
I would like to do this in NODEJS, to return all the PID from the computer, not only from nodejs
0
I would like to know how to take all processes with the nodejs equal to the c#
Process[] processlist = Process.GetProcesses();
I would like to do this in NODEJS, to return all the PID from the computer, not only from nodejs
0
Yes, Voce needs to use process = require('process'); so
To get the process you need the process ID:
if (process.pid) {
console.log('Este processo é seu pid' + process.pid);
}
To take from the platform:
console.log('Esta plataforma é ' + process.platform);
Update to your requirements. (Test WINDOWS)
var exec = require('child_process').exec;
var yourPID = '1444';
exec('tasklist', function(err, stdout, stderr) {
var lines = stdout.toString().split('\n');
var results = new Array();
lines.forEach(function(line) {
var parts = line.split('=');
parts.forEach(function(items){
if(items.toString().indexOf(yourPID) > -1){
console.log(items.toString().substring(0, items.toString().indexOf(yourPID)));
}
})
});
});
In linux it is something like this:
var spawn = require('child_process').spawn,
cmdd = spawn('your_command'); //something like: 'man ps'
cmdd.stdout.on('data', function (data) {
console.log('' + data);
});
cmdd.stderr.setEncoding('utf8');
cmdd.stderr.on('data', function (data) {
if (/^execvp\(\)/.test(data)) {
console.log('Failed to start child process.');
}
});
Browser other questions tagged node.js list process
You are not signed in. Login or sign up in order to post.
There is no native way to do this on the Node. Take a look here: http://stackoverflow.com/q/33583340/2256325. until an answer arises here
– Sergio