Figure out processes startup environment

Sometimes it is necessary to figure out what environment variables a process was started with. If you're on a *nix system having a procfs you can just take a look in /proc/<pid>/environ.

This is a sample from a server running a PostgreSQL instance:

roppert@piper ~ $ ps aux | grep postgres
postgres 23603  0.0  1.0  37996  3864 ?        Ss   Dec02   0:05 /usr/lib/postgresql-8.3/bin/postgres --silent-mode=true
postgres 23606  0.0  1.0  37996  3896 ?        Ss   Dec02   0:00 postgres: writer process                               
postgres 23607  0.0  1.0  37996  3880 ?        Ss   Dec02   0:00 postgres: wal writer process                           
postgres 23608  0.0  1.0  37996  3940 ?        Ss   Dec02   0:00 postgres: autovacuum launcher process                  
postgres 23609  0.0  0.6   9316  2408 ?        Ss   Dec02   0:07 postgres: stats collector process                      
roppert  31814  0.0  0.1   4612   740 pts/4    R+   23:29   0:00 grep --colour=auto postgres
roppert@piper ~ $ sudo cat /proc/23603/environ 
TERM=screenSHELL=/bin/bashUSER=postgresPATH=/bin:/usr/bin_=/usr/lib/postgresql-8.3/bin/postgresPWD=/var/lib/postgresqlPGLOCALEDIR=/usr/share/postgresql-8.3/localePGSYSCONFDIR=/etc/postgresql-8.3HOME=/var/lib/postgresqlSHLVL=2LOGNAME=postgresPGDATA=/var/lib/postgresql/8.3/datarobertg@piper ~ $ 

I have no clue on how to do this on a Windows system. Anyone?


Kommentarer
Postat av: lericson

On Windows? Of course you can. Windows has CreateRemoteThread.

2009-02-26 @ 11:51:59

Kommentera inlägget här:

Namn:
Kom ihåg mig?

E-postadress: (publiceras ej)

URL/Bloggadress:

Kommentar:

Trackback
RSS 2.0