environment setup problem with "env -"
Mon Jan 12 21:10:00 GMT 2004
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
>> >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
> rc = CreateProcess (myself->progname, /* image to run */
> myself->progname, /* what we send in arg0 */
> TRUE, /* inherit handles from parent */
>----> NULL, /* environment filled in later */
> 0, /* use current drive/directory */
>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
More information about the Cygwin-developers