When an (msys) application launches another program via exec() or
spawn(), it uses the msys implementation of those functions. These
implementations are smart, and can detect when the to-be-launched
application is a non-msys (that is, native w32) app, and translates all
the environment variables (like PATH, etc) from unix to win32 format.
However, if you have an (msys) application that launches another app via
the Windows CreateProcess API (like, for instance, run.exe or
cygstart.exe), then the launcher app needs to manually synchronize the
win32 environment with the msys environment -- and translate those env
vars. The details of this task really belong inside msys, not in a
bunch of separate applications. Cygwin added the CW_SYNC_WINENV
cygwin_internal function four years ago; the attached patch implements
it for MSYS.
The patch also (a) adds a few additional vars to MSYS's list of "make
sure these are always defined" variables, based on today's cygwin
implementation, (b) cleans up the implementation of cygwin_internal to
ensure that va_end() is always called, and sets errno to ENOSYS for bad
2010.09.04 Charles Wilson <...>
* environ.cc (forced_winenv_vars): Ensure that HOMEDRIVE,
HOMEPATH, PATH, USERDOMAIN, USERNAME, USERPROFILE, and WINDIR
environment variables exist.
* external.cc (sync_winenv): New function.
(cygwin_internal): Ensure that va_arg is cleaned up before
return. Set errno on bad call. Support new CW_SYNC_WINENV option.
* include/cygwin/version.h: Bump API version number.
* include/sys/cygwin.h: Define CW_SYNC_WINENV.
Ok to commit?
From: Cesar Strauss <cestrauss@gm...> - 2010-09-07 02:00:27
On 4/9/2010 23:10, Charles Wilson wrote:
> 2010.09.04 Charles Wilson<...>
> * environ.cc (forced_winenv_vars): Ensure that HOMEDRIVE,
> HOMEPATH, PATH, USERDOMAIN, USERNAME, USERPROFILE, and WINDIR
> environment variables exist.
> * external.cc (sync_winenv): New function.
> (cygwin_internal): Ensure that va_arg is cleaned up before
> return. Set errno on bad call. Support new CW_SYNC_WINENV option.
> * include/cygwin/version.h: Bump API version number.
> * include/sys/cygwin.h: Define CW_SYNC_WINENV.
Patch looks good, seems to build and run fine.
> Ok to commit?
version.h is at revision 1.18 right now, it seems you need to update
your CVS tree.
From: Charles Wilson <cwilso11@us...> - 2010-09-08 17:13:48
On 9/6/2010 9:59 PM, Cesar Strauss wrote:
>> Ok to commit?
> OK, thanks.
> version.h is at revision 1.18 right now, it seems you need to update
> your CVS tree.
Updated, merged, and committed.