mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
1. Added 'getProcess' to process-manager for posix platforms with pgrep
2. Fixed parsing bug in user-sessions.getEnvFromPid 3. Updated linux-gnome-helpers to set environment and uid before calling gsettings
This commit is contained in:
@@ -189,6 +189,33 @@ function processManager() {
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(this, '_pgrep', {
|
||||
value: (function ()
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write("whereis pgrep | awk '{ print $2 }'\nexit\n");
|
||||
child.waitExit();
|
||||
return (child.stdout.str.trim());
|
||||
})()
|
||||
});
|
||||
|
||||
if(this._pgrep != '')
|
||||
{
|
||||
this.getProcess = function getProcess(cmd)
|
||||
{
|
||||
var child = require('child_process').execFile(this._pgrep, ['pgrep', cmd]);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||
child.waitExit();
|
||||
if (child.stderr.str != '') { throw (child.stderr.str.trim()); }
|
||||
if (child.stdout.str.trim() == '') { throw (cmd + ' not found'); }
|
||||
|
||||
return (parseInt(child.stdout.str.trim()));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new processManager();
|
||||
|
||||
Reference in New Issue
Block a user