Is it possible to get relevant information from /proc/pid/environ
file if process modified its environment? My tests show that setenv/putenv/clearenv
don't update environ
file. However, in bash
its possible to call unset ENV
and see changes in procfs.
setenv/clearenv + procfs environ
This author wrote a three (but not four) part explanation of why it doesn't already work. codywu2010.wordpress.com/2014/09/14/… codywu2010.wordpress.com/2014/09/14/… codywu2010.wordpress.com/2014/09/15/… –
Reliant
I also found some Perl folks trying to figure this out: perlmonks.org/?node_id=303181 –
Reliant
Ultimately, I believe this is not possible (despite really hoping it is). My guess why you're seeing different behavior in bash is that however you're checking the environment is actually running in a subshell. –
Reliant
@Reliant I tried my bash example and it didn't worked. So might be that I was indeed mistaken in the first place. Seems like its indeed impossible. You can add this as an answer if you want. –
Nostradamus
According to man proc
, under /proc/[pid]/environ
,
If, after an execve(2), the process modifies its environment (e.g., by calling functions such as putenv(3) or modifying the environ(7) variable directly), this file will not reflect those changes.
So, it doesn't appear to be possible.
© 2022 - 2024 — McMap. All rights reserved.