proc

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)

Subscribe to RSS - proc