Environment Variables in Linux
Last week, one of my friend who's new to Linux asked me some quesitons about environment variables in Linux. It was not too difficult for me to answer her questions, but it trigged me to think how does Linux handles environment variables. Where does the system store the environment variables? According to the Wikipedia page , "in all Unix and Unix-like systems, as well as on Windows, each process has its own separate set of environment variables. By default, when a process is created, it inherits a duplicate run-time environment of its parent process, except for explicit changes made by the parent when it creates the child. At the API level, these changes must be done between running fork and exec." Hey, this gave us some hit that the handling of environment variables is related with function call fork and exec. Thanks to the people who created the manual page for the exec function call, I noticed it mentioned some external variable named environ as part of the...