Environment Variables
Environment variables are a facility provided by some operating systems. Within the OS's shell (ksh in Unix, bash in Linux, command.com in DOS and cmd.exe in Windows) they are a kind of variable: for instance, in unix and related systems an ordinary variable becomes an environment variable when the export
keyword is used. Program code other than shells has to access them by API calls, such as getenv
and setenv
.
They are local to the process in which they were set. That means if we open two terminal windows (Two different processes running shell) and change value of environment variable in one window, that change will not be seen by other window.
When a child process is created, it inherits all the environment variables and their values from the parent process. Usually, when a program calls another program, it first creates a child process by forking, then the child adjusts the environment as needed and lastly the child replaces itself with the program to be called. Child processes therefore cannot use environment variables to communicate with their peers, avoiding the action at a distance problem.
Read more about this topic: Global Variable
Famous quotes containing the words environment and/or variables:
“For those parents from lower-class and minority communities ... [who] have had minimal experience in negotiating dominant, external institutions or have had negative and hostile contact with social service agencies, their initial approaches to the school are often overwhelming and difficult. Not only does the school feel like an alien environment with incomprehensible norms and structures, but the families often do not feel entitled to make demands or force disagreements.”
—Sara Lawrence Lightfoot (20th century)
“Science is feasible when the variables are few and can be enumerated; when their combinations are distinct and clear. We are tending toward the condition of science and aspiring to do it. The artist works out his own formulas; the interest of science lies in the art of making science.”
—Paul Valéry (18711945)