4 ms·
Is this true on other OSs? On Windows at least env vars are inherited and will not change in a long running process if changed elsewhere. So you can do somethi
by hnick 5y ago
Is this true on other OSs? On Windows at least env vars are inherited and will not change in a long running process if changed elsewhere.
So you can do something like nuke $ENV{PATH} in your perl script and it'll apply to any subsequent child system() calls.
- p_l 5y agoon POSIX, environment variables is just a pointer to an array of pointers to NAME=VALUE strings, terminated with NULL. The contents are private to a process, and the only method to modify them from outside the process is to have write access to process memory and change the pointer to the memory block. When you start a new process, ultimately your calls turn into execve family with full set of arguments, i.e. actual binary to replace your process with, arguments, and contents of the environment it's going to use. The wrapper functions that don't ask for new environ value simply copy the current one.