environment setup problem with "env -"

Igor Pechtchanski pechtcha@cs.nyu.edu
Mon Jan 12 20:27:00 GMT 2004

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
> >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 */
                      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()?

> I've been overruled by Microsoft all of last week as I attempt to fix
> the problems on WinME, in fact.  My wife is getting tired of saying
> "Don't worry you'll figure it out, honey".
> In honing my skills for this problem, I've managed to bend steel bars
> with my mind and cause fires to start from a distance but I haven't been
> able to penetrate the inscrutable "pwd has caused a problem with
> cygwin1.dll" errors.  I just can't seem to master the ancient art of
> Windows telepathy.
> cgf

Well, WinME probably has its own brand of telepathy that's incompatible
with all the other Windows versions...
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

More information about the Cygwin-developers mailing list