http://bugs.winehq.org/show_bug.cgi?id=21291
Summary: System call "dup2" doesn't retain text vs binary mode Product: Wine Version: 1.0.1 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt AssignedTo: wine-bugs@winehq.org ReportedBy: simon@josefsson.org
Hi again, here is another "dup2" problem.
The attached code example behaves different in Wine compared to Windows XP. Under Wine it will print:
is_mode 1 dup2 3 => 0 is_mode 0
Note the last 'is_mode 0' which is the actual error. On Windows XP it prints:
is_mode 1 dup2 3 => 0 is_mode 1
The bug in the Wine "dup2" implementation appears to be that it doesn't copy the text/binary setting to the new file descriptor. Fixing it may be rather simple.
/Simon
jas@mocca:~$ cat foo2.c #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <stdio.h>
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get declarations of the Win32 API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h> #endif
/* Return non-zero if FD is open in the given MODE, which is either O_TEXT or O_BINARY. */ static int is_mode (int fd, int mode) { int value = setmode (fd, O_BINARY); setmode (fd, value); return mode == value; }
int main (void) { const char *file = "test-dup2.tmp"; int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600);
setmode (fd, O_TEXT); printf ("is_mode %d\n", is_mode (fd, O_TEXT)); printf ("dup2 %d => %d\n", fd, dup2 (fd, fd + 1)); printf ("is_mode %d\n", is_mode (fd + 1, O_TEXT));
return 0; } jas@mocca:~$ i586-mingw32msvc-gcc -o foo2.exe foo2.c jas@mocca:~$ wine --version wine-1.0.1 jas@mocca:~$ wine ./foo2.exe is_mode 1 dup2 3 => 0 is_mode 0 jas@mocca:~$
http://bugs.winehq.org/show_bug.cgi?id=21291
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=21291
Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |bon@elektron.ikp.physik.tu- | |darmstadt.de Resolution| |FIXED
--- Comment #1 from Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de 2010-01-16 11:25:44 --- /tmp> i386-mingw32msvc-gcc test.c /tmp> ~/.wine/wine-git/wine a.exe is_mode 1 dup2 3 => 0 is_mode 1 /tmp> env WINEDLLOVERRIDES=msvcrt=n ~/.wine/wine-git/wine a.exe is_mode 1 dup2 3 => 0 is_mode 1 /tmp> wine --version wine-1.1.36
For me it seems to bug is resolved.
http://bugs.winehq.org/show_bug.cgi?id=21291
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #2 from Alexandre Julliard julliard@winehq.org 2010-01-22 11:02:29 --- Closing bugs fixed in 1.1.37.