This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: environment setup problem with "env -"


On Mon, Jan 12, 2004 at 03:27:14PM -0500, Igor Pechtchanski wrote:
>On Mon, 12 Jan 2004, Christopher Faylor wrote:
>
>> On Mon, Jan 12, 2004 at 02:24:01PM -0500, Igor Pechtchanski wrote:
>> >FWIW, here's what I get on my machine:
>> >
>> >$ env - /bin/env
>> >HOMEDRIVE=C:
>> >HOMEPATH=\
>> >LOGONSERVER=\\PECHTCHA
>> >SYSTEMDRIVE=C:
>> >SYSTEMROOT=C:\WINNT
>> >USERDOMAIN=PECHTCHA
>> >USERNAME=igor
>> >USERPROFILE=C:\Documents and Settings\igor
>> >$
>> >
>> >Using "/bin/sh -c set" adds IFS, PATH, PS1, and PS2.
>>
>> That's what I remember from our previous investigations into this
>> matter.  I didn't like the fact that we couldn't actually eliminate all
>> of the environment if that's what the user asked to do but I was
>> overruled by Microsoft.
>
>I've looked at fork_parent() in fork.cc (below, note the line marked with
>an arrow):
>
>  rc = CreateProcess (myself->progname, /* image to run */
>                      myself->progname, /* what we send in arg0 */
>                      sec_attribs,
>                      sec_attribs,
>                      TRUE,       /* inherit handles from parent */
>                      c_flags,
>---->                 NULL,       /* environment filled in later */
>                      0,          /* use current drive/directory */
>                      &si,
>                      &pi);
>
>According to MSDN, if the environment parameter is NULL, it will be
>inherited from the parent process.  I'm not sure if this is significant,
>but spawn_guts() in spawn.cc explicitly passes the environment pointer to
>CreateProcess, rather than inheriting the parent's one.  Is there a
>particular reason this isn't done in fork_parent()?

The environment is irrelevant to the forked child since it is filled in
by copying everything from the parent.  When spawn/exec builds the
environment to send to a process it uses the information from cygwin's
environ table.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]