I'm currently using the Bash command ps eww
in order to get the environment variable of all processes.
For example, If I run the following command :
a=a b=b c=c sleep 1000
The output of ps eww | grep sleep
would be:
23709 s007 S 0:00.00 sleep 1000 a=a b=b c=c TERM_PROGRAM=Apple_Terminal ...
In python, I've read about psutil
package which has environ()
method for extracting environment variables but it apply to current process or parent/child only (i.e. psutil.Process().environ()
or psutil.Process().Parent().environ()
etc..).
Perhaps there's a way to get the environment for every living process (according to name or any other attribute) ?
preferably, this option will comes on embedded package as part of python 2.7.1x
thanks