http://bugs.winehq.org/show_bug.cgi?id=25062
Summary: popen: the stderr from the child process is (wrongly) redirected to the parent's stdin Product: Wine Version: 1.2 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt AssignedTo: wine-bugs@winehq.org ReportedBy: borut.razem@gmail.com
When a child process is popened in read mode, the child's stdout and stderr are both redirected do parent's stdin, which is wrong: only the child's stdout shoud be redirected, child's stderr should be the same as (inherited from) the parent's stderr.
In the following example the "This is stdout" text should be displayd in upper-case: "THIS IS STDOUT", and the "This is stderr" should be displayed in lower-case.
Both child.c and parent.c should be compiled, executables should be located in the same directory and parent.exe should be executed.
I compiled the example in three different ways: 1) msvc 6.0 using static libraries on Windows 2) msvc 6.0 using msvcrt.dll compilation on Windows 3) mingw using msvcrt.dll cross-compilation on Linux
All three executables works correctly on Windows platforms (tested on Windows XP), while ony the no. 1) woks correctly on Linux + Wine: it uses the statically linked popen implementation from msvc library. No. 2) and no. 3) display incorrect uppercase "THIS IS STDERR": they both use the Wine msvcrt.dll.
I think that this proves that the bug is in the Wine msvcrt.dll popen implementation.
Example:
child.c: ----8<---- #include <stdio.h>
int main (void) { fprintf (stdout, "This is stdout\n"); fprintf (stderr, "This is stderr\n"); return 0; } ---->8----
parent.c: ----8<---- #include <stdio.h> #include <ctype.h>
int main (void) { FILE *fp;
if (NULL != (fp = _popen(".\child", "rt"))) { int c;
while (EOF != (c = getc (fp))) putc (toupper (c), stdout); _pclose (fp);
return 0; } else { perror ("parent"); return 1; } } ---->8----
I took a look to the popen implementation in wine-1.3.6/dlls/msvcrt/process.c, function MSVCRT__wpopen(): all special handling of fdStdErr in case of readPipe seems suspicious to me...
Borut