X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Wed, 18 Jun 2008 08:04:12 -0400 From: Mike Mueller To: cygwin AT cygwin DOT com Subject: Re: Cygwin app not receiving modified PATH env var Message-ID: <20080618120412.GH7632@samus.subfocal.net> References: <20080617034152 DOT GD7632 AT samus DOT subfocal DOT net> <20080618010536 DOT GE7632 AT samus DOT subfocal DOT net> <20080618080059 DOT GF7632 AT samus DOT subfocal DOT net> <20080618085118 DOT GB20180 AT calimero DOT vinschen DOT de> <20080618093016 DOT GG7632 AT samus DOT subfocal DOT net> <20080618103022 DOT GC20180 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080618103022.GC20180@calimero.vinschen.de> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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/