3 ms·
on 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, a
by p_l 5y ago
on 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.