NUEVA BUSQUEDA DE DATOS SRI
This commit is contained in:
19
node_modules/pstree.remy/lib/tree.js
generated
vendored
19
node_modules/pstree.remy/lib/tree.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
module.exports = function(rootPid, callback) {
|
||||
const tree = {};
|
||||
module.exports = function (rootPid, callback) {
|
||||
const pidsOfInterest = new Set([parseInt(rootPid, 10)]);
|
||||
var output = '';
|
||||
|
||||
// *nix
|
||||
const ps = spawn('ps', ['-A', '-o', 'ppid,pid']);
|
||||
ps.stdout.on('data', data => {
|
||||
ps.stdout.on('data', (data) => {
|
||||
output += data.toString('ascii');
|
||||
});
|
||||
|
||||
@@ -15,12 +15,15 @@ module.exports = function(rootPid, callback) {
|
||||
const res = output
|
||||
.split('\n')
|
||||
.slice(1)
|
||||
.map(_ => _.trim())
|
||||
.map((_) => _.trim())
|
||||
.reduce((acc, line) => {
|
||||
if (line.indexOf(rootPid + ' ') === 0) {
|
||||
const pid = line.split(/\s+/).pop();
|
||||
acc.push(parseInt(pid, 10));
|
||||
rootPid = pid;
|
||||
const pids = line.split(/\s+/);
|
||||
const ppid = parseInt(pids[0], 10);
|
||||
|
||||
if (pidsOfInterest.has(ppid)) {
|
||||
const pid = parseInt(pids[1], 10);
|
||||
acc.push(pid);
|
||||
pidsOfInterest.add(pid);
|
||||
}
|
||||
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user