Re: Issue 52 in psutil: Determine process environment variables

19 views
Skip to first unread message

psu...@googlecode.com

unread,
Feb 4, 2010, 8:45:53 AM2/4/10
to psutil-...@googlegroups.com
Updates:
Labels: Milestone-0.2.0

Comment #5 on issue 52 by billiej...@gmail.com: Determine process
environment variables
http://code.google.com/p/psutil/issues/detail?id=52

(No comment was entered for this change.)

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

psu...@googlecode.com

unread,
Feb 26, 2010, 5:04:59 AM2/26/10
to psutil-...@googlegroups.com

Comment #6 on issue 52 by wj32.64: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

I'm the guy who helped you with the command line retrieval on Windows.
Please ignore
those CreateRemoteThread idiots. Take a look at this code (function
PhGetProcessEnvironmentVariables):

http://processhacker.svn.sourceforge.net/viewvc/processhacker/2.x/trunk/ProcessHacker/native.c?revision=HEAD&view=markup

psu...@googlecode.com

unread,
Jul 9, 2010, 4:14:48 PM7/9/10
to psutil-...@googlegroups.com
Updates:
Labels: -Progress-0in4 Progress-1in4

Comment #8 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Just for the record when we'll reconsider this, Linux code was committed as
r406 and removed in r464 and r599.

psu...@googlecode.com

unread,
Mar 1, 2011, 1:02:50 PM3/1/11
to psutil-...@googlegroups.com

Comment #10 on issue 52 by g.rod...@gmail.com: Determine process
environment variables
http://code.google.com/p/psutil/issues/detail?id=52

On FreeBSD we can use kvm_getenvv():
http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?kvm_getenvv+3

psu...@googlecode.com

unread,
Jan 24, 2012, 4:24:07 PM1/24/12
to psutil-...@googlegroups.com

Comment #11 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Issue 247 has been merged into this issue.

psu...@googlecode.com

unread,
Jan 31, 2012, 11:42:44 AM1/31/12
to psutil-...@googlegroups.com

Comment #12 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Another article about Windows:
http://www.codeproject.com/Articles/25647/Read-Environment-Strings-of-Remote-Process

psu...@googlecode.com

unread,
Feb 1, 2012, 1:23:33 PM2/1/12
to psutil-...@googlegroups.com
Updates:
Status: ReOpened
Labels: Milestone-0.5.0

Comment #13 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Reopening as I have a partial working patch for Windows.
I'd like to have this ready for 0.5.0.

psu...@googlecode.com

unread,
Feb 1, 2012, 2:10:31 PM2/1/12
to psutil-...@googlegroups.com
Updates:
Labels: -Progress-1in4 Progress-2in4

Comment #14 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Linux implementation readded as r1259.
Windows implementation added as r1260.

psu...@googlecode.com

unread,
Feb 1, 2012, 5:54:00 PM2/1/12
to psutil-...@googlegroups.com

Comment #15 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

kvm_getenvv() on FreeBSD can only be used if /proc filesystem is mounted
(and it's not by default).
Partial implementation is below but I guess we better off not supporting
FreeBSD at all.

static PyObject*
get_process_environ(PyObject* self, PyObject* args)
{
long pid;
char **env;
struct kinfo_proc *pinfo;
int num;
static kvm_t **kd;

if (! PyArg_ParseTuple(args, "l", &pid)) {
return NULL;
}

kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);

pinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &num);
if (pinfo == NULL) {
return PyErr_SetFromErrno(PyExc_OSError);
}

env = kvm_getenvv(kd, pinfo, 9086);
if (env == NULL) {
return PyErr_SetFromErrno(PyExc_OSError);
}

return Py_BuildValue("i", 33);
}

psu...@googlecode.com

unread,
Apr 25, 2012, 12:46:31 AM4/25/12
to psutil-...@googlegroups.com
Updates:
Cc: g.rodola

Comment #16 on issue 52 by david.da...@gmail.com: Determine process
environment variables
http://code.google.com/p/psutil/issues/detail?id=52

I fixed the heap corruption issue happening with the get_process_environ()
call on windows in r1297

psu...@googlecode.com

unread,
Apr 25, 2012, 7:58:05 AM4/25/12
to psutil-...@googlegroups.com

Comment #17 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Great! Thanks.

psu...@googlecode.com

unread,
Apr 25, 2012, 8:57:22 AM4/25/12
to psutil-...@googlegroups.com
Updates:
Status: WaitingForReview

Comment #18 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Looking back at this I start to doubt the usefulness for two reasons:

- on Linux this seems to work just fine but if the environment of the
process is modified the change is not propagated:

>>> p = psutil.Process(os.getpid())
>>> os.putenv('XXX', '1')
>>> 'XXX' in p.get_environ()
False


- on Windows this can be used for the current process only; for all other
processes, including the ones owned by the current user, we get an
AccessDenied exception - also, if the environment of the current process is
changed we also get AccessDenied.


That said, it probably make sense to give up on this.
I'm going to leave this open for a while a take a definitive decision later.

psu...@googlecode.com

unread,
Jun 26, 2012, 1:08:46 PM6/26/12
to psutil-...@googlegroups.com

Comment #19 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

More info about Linux not updating /proc/PID/environ:
http://serverfault.com/questions/66363/environment-variables-of-a-running-process-on-unix/79463#79463

psu...@googlecode.com

unread,
Jun 26, 2012, 1:31:30 PM6/26/12
to psutil-...@googlegroups.com
Updates:
Status: WontFix
Labels: -Milestone-0.5.0

Comment #20 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Ok, I'm still inclined to remove this due to the unreliabilities explained
above for both Windows and Linux. Removal done in r1366 and closing this
out as WontFix.

psu...@googlecode.com

unread,
Mar 1, 2013, 5:05:38 PM3/1/13
to psutil-...@googlegroups.com

Comment #21 on issue 52 by g.rodola: Determine process environment variables
http://code.google.com/p/psutil/issues/detail?id=52

Updated csets after the SVN -> Mercurial migration:
r406 == revision 12039c7bc9e6
r1260 == revision 2fb67bef8d9a
r1297 == revision b0586117177a
r1366 == revision e10ef9b69e00


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages