hacker emblem

Comparing process environments

Using the entry in the proc-Filesystem of a running process, it's easy to get a sorted list of environment variables for a certain process ID (PID):

tr '\0' '\n' < /proc/<PID>/environ | sort

Since the lines in environ are null-terminated, putting proper newlines in the output with tr is necessary before sorting. (sort can only output lines terminated with \0 using the option -z, but not read them, besides: even -z doesn't quite work as expected in my case)

Using the output of above command line comparing two running processes is easy, using diff or vimdiff (even remotely, see my last blog post)

read more | admin's blog | 1 comment

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
The content of this field is kept private and will not be shown publicly.
  • Textual smileys will be replaced with graphical ones.
  • Lines and paragraphs break automatically.
More information about formatting options