1
0
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:
Bryan Roe
2019-06-22 01:12:15 -07:00
parent de0f88188f
commit c9f0bff898

View File

@@ -596,6 +596,8 @@ 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
{ {
@@ -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)