mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-18 09:13:14 +00:00
update to getEnvFromPid() for freebsd
This commit is contained in:
@@ -596,6 +596,8 @@ function UserSessions()
|
||||
this.getEnvFromPid = function getEnvFromPid(pid)
|
||||
{
|
||||
var ret = {};
|
||||
if (process.platform == 'linux')
|
||||
{
|
||||
var ps, psx, v, vs = 0;
|
||||
try
|
||||
{
|
||||
@@ -615,6 +617,21 @@ function UserSessions()
|
||||
vs = psx + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (process.platform == 'freebsd')
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stdin.write("procstat -e " + pid + " | grep " + pid + " | awk '{ $1=\"\"; $2=\"\"; print $0 }' | tr \"\\ \" \"\\n\" | awk -F= '{ if($1==\"\") { print $0 }}'\nexit\n");
|
||||
child.waitExit();
|
||||
var env;
|
||||
var tokens = child.stdout.str.trim().split('\n');
|
||||
for(var i in tokens)
|
||||
{
|
||||
env = tokens[i].split('=');
|
||||
ret[env[0]] = env[1];
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
};
|
||||
this.findEnv = function findEnv(uid, env)
|
||||
|
||||
Reference in New Issue
Block a user