Same process has different environmental variables in /proc/pid/environ when seen from different sessions. Why?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
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.
bash process environment-variables vnc proc
add a comment |Â
up vote
1
down vote
favorite
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.
bash process environment-variables vnc proc
1
/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).
â Gilles
Jan 3 at 21:06
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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.
bash process environment-variables vnc proc
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.
bash process environment-variables vnc proc
asked Jan 3 at 17:18
Jeevan Patnaik
1952518
1952518
1
/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).
â Gilles
Jan 3 at 21:06
add a comment |Â
1
/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).
â Gilles
Jan 3 at 21:06
1
1
/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).â Gilles
Jan 3 at 21:06
/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).â Gilles
Jan 3 at 21:06
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Here is what I did for a test:
$export test=one
$vim test1
pid = 1200, Stopped the process with CTRL-Z
$cat /proc/1200/environ | strings
test=one
Now for second process
$test=two
$vim test2
pid = 1201, Stopped the process with CTRL-Z
$cat /proc/1201/environ | strings
test=two
The user might have changed the environment properties before running the program.
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Here is what I did for a test:
$export test=one
$vim test1
pid = 1200, Stopped the process with CTRL-Z
$cat /proc/1200/environ | strings
test=one
Now for second process
$test=two
$vim test2
pid = 1201, Stopped the process with CTRL-Z
$cat /proc/1201/environ | strings
test=two
The user might have changed the environment properties before running the program.
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
add a comment |Â
up vote
1
down vote
accepted
Here is what I did for a test:
$export test=one
$vim test1
pid = 1200, Stopped the process with CTRL-Z
$cat /proc/1200/environ | strings
test=one
Now for second process
$test=two
$vim test2
pid = 1201, Stopped the process with CTRL-Z
$cat /proc/1201/environ | strings
test=two
The user might have changed the environment properties before running the program.
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Here is what I did for a test:
$export test=one
$vim test1
pid = 1200, Stopped the process with CTRL-Z
$cat /proc/1200/environ | strings
test=one
Now for second process
$test=two
$vim test2
pid = 1201, Stopped the process with CTRL-Z
$cat /proc/1201/environ | strings
test=two
The user might have changed the environment properties before running the program.
Here is what I did for a test:
$export test=one
$vim test1
pid = 1200, Stopped the process with CTRL-Z
$cat /proc/1200/environ | strings
test=one
Now for second process
$test=two
$vim test2
pid = 1201, Stopped the process with CTRL-Z
$cat /proc/1201/environ | strings
test=two
The user might have changed the environment properties before running the program.
edited Jan 4 at 5:21
Andy Dalton
4,7841520
4,7841520
answered Jan 3 at 18:00
randominstanceOfLivingThing
21816
21816
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
add a comment |Â
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
I was testing both the sessions in parallel, it shows different environment variables at a time for same process
â Jeevan Patnaik
Jan 3 at 18:19
1
1
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
Does the program modify the environment variables?
â randominstanceOfLivingThing
Jan 3 at 19:27
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
I forgot to do followup on this question. Yes, I had later realized that /proc/pid/environ doesn't actually display realtime environmental variables. But it only shows the environmental variable that were there when the process is started. So, it appears that the environmental variable was changed after the process is started. Thank you!
â Jeevan Patnaik
Mar 9 at 18:51
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f414588%2fsame-process-has-different-environmental-variables-in-proc-pid-environ-when-see%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
/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).â Gilles
Jan 3 at 21:06