Changing environment variables of a child process
Environment variables are key-value pairs associated with a process. They are useful for passing information specific to the environment, such as the current user’s home directory, executable search path, configuration options, and more. In containerized deployments, environment variables are a convenient way to pass the credentials a program needs.
The environment variables for a process are provided by its parent process, but once the process starts, a copy of those provided environment variables is assigned to the child process. Because of this, a parent process cannot change the environment variables of its child process after the child starts running.
How to do it...
- To use the same environment variables as the current process when launching a child process, set
Command.Env
tonil
. That will copy the current process environment variables to the child. - To start the child process using additional environment...