http://bugs.winehq.org/show_bug.cgi?id=2298
Summary: wine messes up child process environment Product: Wine Version: 20040309 Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P3 Component: wine-kernel AssignedTo: wine-bugs@winehq.org ReportedBy: xavim@ubxlab.com CC: xavim@ubxlab.com
When a process calls CreateProcessA (or its C runtime library wrapper _spawn*) to invoke a child process with a newly generated environment, wine modifies this environment before passing it to the child.
Namely, it adds entries for HOME, COMSPEC, PATH, TEMP, TMP, windir and winsysdir variables.
This behaviour is incompatible with Windows, as the following example shows:
<code filename="parent.c"> #include <process.h> #include <stdio.h>
int main(int argc, char *argv[]) { char *child_env[] = { "entry_0", "entry_1", "entry_2", NULL }; char cmdname[] = "child.exe";
printf("Parent started.\n"); _spawnle(_P_WAIT, cmdname, cmdname, NULL, child_env);
return 0; } </code>
<code filename="child.c"> #include <stdio.h> #include <stdlib.h>
static void print_env(char **env);
int main(int argc, char *argv[]) { printf("Child started.\n"); printf("In child: "); print_env(_environ);
return 0; }
static void print_env(char **env) { printf("env = [ "); if (env != NULL) { while (*env != NULL) { printf("%s, ", *env); ++env; } } printf("]\n"); } </code>
After compiling these two programs with MinGW under Win98SE, we get the following output:
Running in Win98 (SE):
E:...>parent.exe Parent started. Child started. In child: env = [ entry_0, entry_1, entry_2, ]
E:...>
Running wine under Debian (unstable):
$ wine parent.exe Parent started. Child started. In child: env = [ HOME=/home/javi, entry_0, entry_1, entry_2, COMSPEC=C:\WINDOWS\SYSTEM\wcmd.exe, PATH=C:\syntech\bin;C:\Windows;C:\Windows\system;X:;X:\test;Y:, TEMP=C:\TMP, TMP=C:\TMP, windir=C:\WINDOWS, winsysdir=C:\WINDOWS\SYSTEM, SYSTEMROOT=C:\WINDOWS, ] Wine exited with a successful status $ $ wine --version Wine 20040309 Wine exited with a successful status $ uname -a Linux pandora 2.4.22 #1 Sat Oct 11 23:23:24 CEST 2003 i686 GNU/Linux $
This incompatibility is giving some problems because of the following:
Due to the old DOS restriction about command line length (I think it was about max. 127 bytes), some command line tools used to pass arguments using the environment. When this tools were ported to Win32, this behaviour remained.
Because of this behaviour, when wine messes up the environment, the child process complains about "Bad arguments" and exits.
I am having this problem with a Win32 Toshiba toolchain for a microcontroller. The C compiler is actually a driver that invokes child process to perform the different compilation phases, and they fail for the aforementioned reason.