[MR <MR@FLEXAUT.TUWIEN.AC.AT> writes:]
>But this is not the only reason why I'm writing. Could you please give
>an explanation of the subdirectories below /env/, especially /env/# ?
/env is the environment server. It is a hierarchical name space like most
filesystems, but has the special property that a lookup will keep checking
in ".." until it reaches the top. So if you have:
File Contents
/env/XYZ foo
/env/vandys/XYZ bar
Then getenv() for me, vandys, will return "bar", but everybody else would
see "foo". This is because getenv() starts from /env/USER (actually,
/env/USER/#, but I'll get to that in a second) when it tries to find the
environment variable XYZ. For vandys it finds /env/vandys/XYZ, but for,
say, "joe", it tries /env/joe/XYZ, doesn't find it, tries /env/XYZ, finds
it, and returns that value.
Note that:
echo -n bletch > /env/XYZ
would change the environment variable on the fly for everybody except
vandys, who would continue to see the value in /env/vandys/XYZ.
Now, the wrinkle is how to preserve per-process environment variable
semantics for those cases where this is really what you want. The directory
"#" is a special directory which conceptually resides in /env/USER/#.
Unlike any other directory, entries within it are copy-on-write. If one of
my processes setenv()'s XYZ to "one", the entry /env/vandys/#/XYZ is filled
in with this value. If my process then fork()'s, the # node is
transparently converted so that both parent and child processes see a
/env/vandys/#/XYZ. But if either changes it, their change remains private
to themselves. Thus, environment variables in /env/user/# behave like old,
classic environment variables, while variables elsewhere in the /env
hierarchy behave like global system variables in a arbitrarily hierarchical
namespace.
BTW, /env/# is just a shortcut for /env/USER/#, for the purposes of how the
/env/server is used. #'s location is set by mkdir'ing this name at the
point below which you want to maintain your process-private names. For
VSTa's current login and friends, this is /env/USER/#. Doing it this way
spares the /env server having to know about user names and such. After
you've done this, # means this location no matter what path you use to
access it.
Andy
Received on Sun Apr 17 11:04:09 1994
This archive was generated by hypermail 2.1.8 : Wed Sep 21 2005 - 21:02:16 PDT