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:
“If the Revolution has the right to destroy bridges and art monuments whenever necessary, it will stop still less from laying its hand on any tendency in art which, no matter how great its achievement in form, threatens to disintegrate the revolutionary environment or to arouse the internal forces of the Revolution, that is, the proletariat, the peasantry and the intelligentsia, to a hostile opposition to one another. Our standard is, clearly, political, imperative and intolerant.”
—Leon Trotsky (18791940)
“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)