I was checking environmental variables of bash process of an xterm that was started inside vnc session.
If I check the environmental variables from the bash session itself by running env or cat /proc/pid/environ | strings
, it shows all the environmental variables that would generally be set when we do su or ssh i.e., from /etc/profile and .bashrc. But when I do cat /proc/pid/environ | strings
from a putty session, it shows completely different variables.
Putting aside why only those specific variables are set, I want to know why environ of same process has different results when checked from different sessions like a double slit experiment. I understand that proc is not real filesystem. But what exactly is happening when I'm querying it and so is proc not realiable way to check remote process environment?
I wrote the question from my phone. So, I don't have any sample output to show. But, I hope you get my question.
/proc/pid/environ
is a pretty straightforward dump of a piece of memory. It's the same piece of memory no matter what process asks the kernel to dump it. Given your vague description, my impression is that you're looking at different processes (different PIDs, or same PID on different machines, or same PID in different PID namespaces).