This is the mail archive of the cygwin 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: Cygwin app not receiving modified PATH env var


On Wed, Jun 18, 2008 at 12:30:22PM +0200, Corinna Vinschen wrote:
> As I said, PATH is fetched with GetEnvironmentStrings from the env like
> every other environment var, if the Cygwin app has been started by a
> native parent.  It's just massaged into a POSIX path afterwards.
> There's no magic involved like, say, some hidden mechanism to get the
> environment from the grandparent or something.
> 
> Try this:
> [snip]

Yeah, the command line tricks work for me too.  If I modify the path in
cmd.exe, then invoke bash, its PATH looks correct.

This is slightly different than what my code is doing though.  I've been
trying to avoid modifying my application's (the parent that is) PATH, so
I create a new environment and pass it to CreateProcessW.  Your cmd.exe
scenario has the parent modify its own environment first.

In fact, I just modified my application to call SetEnvironmentVariableW
with the modified PATH, prior to invoking a child.  The other two vars
that I set are still set by grabbing a copy of the environment (after I
modified PATH) and inserting them into the map.  Result: It works.  The
cygwin child app sees all the variables I want it to see.

The downside of this is, well, I don't want to change my parent
process's PATH.  So I can save it, modify it, and revert it, but that's
not exactly thread-safe, since the environment is global to the
application.  It would be ideal if the CreateProcessW method worked.

Thanks for being patient with me; at least I have a workaround, for now.

Thanks,
Mike

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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