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:
“People between twenty and forty are not sympathetic. The child has the capacity to do but it cant know. It only knows when it is no longer able to doafter forty. Between twenty and forty the will of the child to do gets stronger, more dangerous, but it has not begun to learn to know yet. Since his capacity to do is forced into channels of evil through environment and pressures, man is strong before he is moral. The worlds anguish is caused by people between twenty and forty.”
—William Faulkner (18971962)
“The variables of quantification, something, nothing, everything, range over our whole ontology, whatever it may be; and we are convicted of a particular ontological presupposition if, and only if, the alleged presuppositum has to be reckoned among the entities over which our variables range in order to render one of our affirmations true.”
—Willard Van Orman Quine (b. 1908)