How to read environment variables of a process | cat /proc/15885/environ | xargs --null --max-args=1
You can read the initial environment of a process from
/proc/<pid>/environ
.
If a process changes it's environment, then in order to read the environment you must have the symbol table for the process and use the
ptrace
system call (for example by using gdb
) to read the environment from the global char **__environ
variable. There isn't any other way to get the value of any variable from a running Linux process.[root@localhost tmp]# cat /proc/15885/environ | xargs --null --max-args=1
LANG=C
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
NOTIFY_SOCKET=/run/systemd/notify
Comments
Post a Comment