On Unix, is there any way that one process can change another\'s environment variables (assuming they\'re all being run by the same user)? A general solution would be best,
Not a direct answer but... Raymond Chen had a [Windows-based] rationale around this only the other day :-
... Although there are certainly unsupported ways of doing it or ways that work with the assistance of a debugger, there’s nothing that is supported for programmatic access to another process’s command line, at least nothing provided by the kernel. ...
That there isn’t is a consequence of the principle of not keeping track of information which you don’t need. The kernel has no need to obtain the command line of another process. It takes the command line passed to the
CreateProcess
function and copies it into the address space of the process being launched, in a location where theGetCommandLine
function can retrieve it. Once the process can access its own command line, the kernel’s responsibilities are done.Since the command line is copied into the process’s address space, the process might even write to the memory that holds the command line and modify it. If that happens, then the original command line is lost forever; the only known copy got overwritten.
In other words, any such kernel facilities would be
However the most likely reason is simply that there's limited use cases for such a facility.