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,12 +596,14 @@ function UserSessions()
|
|||||||
this.getEnvFromPid = function getEnvFromPid(pid)
|
this.getEnvFromPid = function getEnvFromPid(pid)
|
||||||
{
|
{
|
||||||
var ret = {};
|
var ret = {};
|
||||||
|
if (process.platform == 'linux')
|
||||||
|
{
|
||||||
var ps, psx, v, vs = 0;
|
var ps, psx, v, vs = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ps = require('fs').readFileSync('/proc/' + pid + '/environ');
|
ps = require('fs').readFileSync('/proc/' + pid + '/environ');
|
||||||
}
|
}
|
||||||
catch(pse)
|
catch (pse)
|
||||||
{
|
{
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
@@ -615,6 +617,21 @@ function UserSessions()
|
|||||||
vs = psx + 1;
|
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);
|
return (ret);
|
||||||
};
|
};
|
||||||
this.findEnv = function findEnv(uid, env)
|
this.findEnv = function findEnv(uid, env)
|
||||||
|
|||||||
Reference in New Issue
Block a user