who interpretes the environment variables

who interpretes the environment variables

Post by ujjwal bhoo » Fri, 11 Jul 2003 06:45:52



My question is does Operating system interpretes any environment
variable for any purpose?? Or does it just see them as name-value
pairs??

One fact that I know is that OS is always aware that environment
variables exists for example there are system calls to get, set,
unset, clear the environment variables.

But are they used by OS in any way??

For example "PATH" variable is (probably) interpreted by shell and not
by OS.

Thanks and Regards,
Ujjwal

 
 
 

who interpretes the environment variables

Post by Shaun Clowe » Fri, 11 Jul 2003 07:22:37



Quote:> My question is does Operating system interpretes any environment
> variable for any purpose?? Or does it just see them as name-value
> pairs??

It just sees them as strings and does not use them for any purpose, ever
(that I'm aware of).

Quote:> One fact that I know is that OS is always aware that environment
> variables exists for example there are system calls to get, set,
> unset, clear the environment variables.

These are not system calls, they're library calls (libc).

Quote:> But are they used by OS in any way??

Nope.

Quote:> For example "PATH" variable is (probably) interpreted by shell and not
> by OS.

Exactly.

Cheers,
Shaun

 
 
 

who interpretes the environment variables

Post by Andrew Gabri » Fri, 11 Jul 2003 09:54:01






>> My question is does Operating system interpretes any environment
>> variable for any purpose?? Or does it just see them as name-value
>> pairs??

> It just sees them as strings and does not use them for any purpose, ever
> (that I'm aware of).

>> One fact that I know is that OS is always aware that environment
>> variables exists for example there are system calls to get, set,
>> unset, clear the environment variables.

> These are not system calls, they're library calls (libc).

>> But are they used by OS in any way??

> Nope.

>> For example "PATH" variable is (probably) interpreted by shell and not
>> by OS.

> Exactly.

There was a unix varient which allowed environment variables in
symlinks (might have been Apollo, but not 100% sure). This required
the kernel to obtain the environment variable expansion from the
process accessing the link. I don't know the details of how it was
implemented.

--
Andrew Gabriel
Consultant Software Engineer

 
 
 

who interpretes the environment variables

Post by ujjwal bhoo » Fri, 11 Jul 2003 10:55:10





> > My question is does Operating system interpretes any environment
> > variable for any purpose?? Or does it just see them as name-value
> > pairs??

> It just sees them as strings and does not use them for any purpose, ever
> (that I'm aware of).

> > One fact that I know is that OS is always aware that environment
> > variables exists for example there are system calls to get, set,
> > unset, clear the environment variables.

> These are not system calls, they're library calls (libc).

> > But are they used by OS in any way??

> Nope.

So the next question is "is OS at all aware of existence of
env-variable or it just treate them as part of address space of
process"
For example consider following cases
1. On fork os duplicates the address space of parent process, so all
env-var also gets duplicated as side effect, without OS explicitly
knowing about env-vars. So os is not aware of env-vars in this case.

2. On exec the env-vars might be provided just like command line args,
so it seems here that OS must put them near stack. BUT it do not have
to be like that, for example after exec we can set env variable in
user context by using functions like setenv(). So os is not aware of
env-vars in this case also.

Please correct me if I am wrong.

-Ujjwal Bhoota

- Show quoted text -

Quote:

> > For example "PATH" variable is (probably) interpreted by shell and not
> > by OS.

> Exactly.

> Cheers,
> Shaun

 
 
 

who interpretes the environment variables

Post by David Schwart » Fri, 11 Jul 2003 12:17:55



Quote:> 2. On exec the env-vars might be provided just like command line args,
> so it seems here that OS must put them near stack. BUT it do not have
> to be like that, for example after exec we can set env variable in
> user context by using functions like setenv(). So os is not aware of
> env-vars in this case also.

    The OS must stash (a copy of) the environment somewhere the new process
can get it. Most operating systems do this the same way they do the
arguments. If you have a copy of the Linux kernel source around, check out
fs/exec.c

    DS

 
 
 

1. Why does the cgi environment not inherit environment variables?

When using apache it normally inherits the environment in which it was
started and keeps this environment for executing cgi scripts. For example:
if root has oracle environment variables such as ORACLE_SID set when
starting the server then these are normally available to cgi scripts when
they execute much like the path is. However sometimes and specifically this
time they are not. Could someone explain how this works? It seems to be
somewhat random to me. I've had situations where various instances of the
server had different paths than others.

I'm running apache 1.3.4 and apache 1.3.6 on solaris 2.7 with mod_perl 1.18
and 1.19 respectively.

Matt

2. Was I hacked?

3. how to export shell environment variables to the primary environment?

4. Diamond Edge 3D and X

5. c shell script; Howto use environement variables to build environment variables and take their value

6. Cyrus w/o inetd

7. Difference between shell variables and environment variables!

8. Read/write FAT/FAT32

9. difference between shell variable and environment variable

10. How to get value of environment variable in variable name?

11. Interactive (interpreted) programming environment?

12. Setting variables in a variable array of null variables

13. 2.x mod_ssl X.509 DN environment variable attributes