X-Spam-Check-By: sourceware.org Message-ID: <43E7D056.10505@mscha.org> Date: Mon, 06 Feb 2006 23:40:22 +0100 From: Michael Schaap Reply-To: cygwin AT cygwin DOT com User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: strange cygstart bug with current Cygwin versions References: <2fc802c00602031305p7574f255g5e67e44cd8b754e AT mail DOT gmail DOT com> <2fc802c00602061329x56784831mb5ab16a12191b2e AT mail DOT gmail DOT com> In-Reply-To: <2fc802c00602061329x56784831mb5ab16a12191b2e@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 6-Feb-2006 22:29, David Picton wrote: > On 2/3/06, Igor Peshansky wrote: > >> Sounds like an instance of >> ... Does it work if >> you "cygstart cmd" and then start word from that cmd shell? If you get >> the same symptoms, please run "set" in that cmd window and compare the >> output with the same in a cmd started via "Start->Run"... >> > > I get the same symptoms, and now I can see what the problem is. The > CMD window shows that TEMP and TMP have retained Cygwin-style > pathnames: > > TEMP=/cygdrive/c/DOCUME~1/dave/LOCALS~1/Temp > TMP=/cygdrive/c/DOCUME~1/dave/LOCALS~1/Temp > > Word works OK if I set TMP to a proper Windows pathname e.g. D:\cygwin\tmp > > Hmm, indeed it does ... Under Cygwin 1.5.18, a process started using the Win32 ShellExecute function (which cygstart uses) inherits the entire Cygwin environment, with the appropriate variables, including TEMP and TMP, converted from POSIX to Windows standard. Under Cygwin 1.5.19, however, it only appears to inherit the following variables: COMSPEC, PATH, PATHEXT, PROMPT, SYSTEMDRIVE and SYSTEMROOT and WINDIR. Some code was added to cygstart last May that copies all enviroment variables from the Cygwin enviroment to the Windows enviroment, if they don't exist there yet. This was apparently needed in some obscure circumstances at the time (regarding "mount -X", I think), but it looks like it is now always necessary. (See and , among others.) This code has no special handling for path conversion. We knew that PATH was already in the Windows environment, so we didn't have to care about that one. But we didn't think of other variables... I had a look at the Cygwin source code, and, in environment.cc, it seems to do path conversion for the following variables: PATH, HOME, LD_LIBRARY_PATH, TMPDIR, TMP and TEMP. So, we should probably do so in cygstart as well... However, I'd rather not have to hardcode all of this in the cygstart source code, since it is bound to get out of sync at some point. So, I'm hoping there is some way to use some Cygwin functionality directly. Is there anyone with a better grasp of Cygwin's environment handling code that could help with this, perhaps? What we basically need to do, is copy the Cygwin environment to the Windows environment, taking care of path conversion for all the appropriate variables. The current code we use is as follows: /* Copy cygwin environment variables to the Windows environment if they're not * already there. */ static void setup_win_environ(void) { char **envp = environ; char *var, *val; char curval[2]; while (envp && *envp) { var = strdup(*envp++); val = strchr(var, '='); *val++ = '\0'; if (GetEnvironmentVariable(var, curval, 2) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) { SetEnvironmentVariable(var, val); } free(var); } } Thanks in advance, - Michael -- 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/