http://bugs.winehq.org/show_bug.cgi?id=22216
Summary: Problem with freopen("CONOUT$", "w", stdout); Product: Wine Version: unspecified Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt AssignedTo: wine-bugs@winehq.org ReportedBy: terra@gnome.org
I am having trouble with code that reads...
has_console = FALSE; { typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); LPFNATTACHCONSOLE MyAttachConsole; HMODULE hmod;
if ((hmod = GetModuleHandle("kernel32.dll"))) { MyAttachConsole = (LPFNATTACHCONSOLE) GetProcAddress(hmod, "AttachConsole"); if (MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) { freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); dup2(fileno(stdout), 1); dup2(fileno(stderr), 2); has_console = TRUE; } } }
The freopen calls should cause stderr and stdout to be redirected to the console. Under wine they are not.
The failure occurs in dlls/kernel32/console.c function OpenConsoleW when it checks creation != OPEN_EXISTING. creation at that point is CREATE_ALWAYS.
Changing the check to allow CREATE_ALWAYS fixes my problem, but may not be right.
(The code is from Gnumeric, btw.)
http://bugs.winehq.org/show_bug.cgi?id=22216
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase
http://bugs.winehq.org/show_bug.cgi?id=22216
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|msvcrt |-unknown
--- Comment #1 from Dmitry Timoshkov dmitry@codeweavers.com 2010-03-31 00:48:23 --- Wine version? Does it work if you run the test from wineconsole?
http://bugs.winehq.org/show_bug.cgi?id=22216
--- Comment #2 from Dmitry Timoshkov dmitry@codeweavers.com 2010-03-31 00:52:52 --- Most likely a duplicate of the bug 5541.
http://bugs.winehq.org/show_bug.cgi?id=22216
--- Comment #3 from M Welinder terra@gnome.org 2010-03-31 07:44:49 ---
Wine version?
Git from a couple of weeks ago, give or take.
Does it work if you run the test from wineconsole?
No difference.
Most likely a duplicate of the bug 5541.
It doesn't look that way to me. WriteConsoleW is not part of the equation here.
http://bugs.winehq.org/show_bug.cgi?id=22216
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.1.41
http://bugs.winehq.org/show_bug.cgi?id=22216
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |kernel32
http://bugs.winehq.org/show_bug.cgi?id=22216
Jerome Leclanche adys.wh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |adys.wh@gmail.com
--- Comment #4 from Jerome Leclanche adys.wh@gmail.com 2011-11-08 09:05:20 CST --- Please retest in wine-1.3.32.
http://bugs.winehq.org/show_bug.cgi?id=22216
Eric Pouech eric.pouech@orange.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED CC| |eric.pouech@orange.fr Ever Confirmed|0 |1
--- Comment #5 from Eric Pouech eric.pouech@orange.fr 2012-02-05 15:24:34 CST --- I've fixed the CreateFileW call that was wrong (called from msvcrt.freopen) but this simple code still doesn't work as AttachConsole isn't implemented yet A+
http://bugs.winehq.org/show_bug.cgi?id=22216
--- Comment #6 from Austin English austinenglish@gmail.com 2012-02-08 17:52:26 CST --- http://source.winehq.org/git/wine.git/commitdiff/d967484ecc1f6a8c4f84b9d04a6...
http://bugs.winehq.org/show_bug.cgi?id=22216
Eric Pouech eric.pouech@orange.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED
--- Comment #7 from Eric Pouech eric.pouech@orange.fr 2012-02-25 14:02:20 CST --- this part (about reopen failing is fixed) AttachConsole still needs to be implemented, but that's another bug report, and it'll wait after 1.4 is out A+
http://bugs.winehq.org/show_bug.cgi?id=22216
--- Comment #8 from Jerome Leclanche adys.wh@gmail.com 2012-02-25 14:04:08 CST --- (In reply to comment #7) Do you remember the commit fixing it?
http://bugs.winehq.org/show_bug.cgi?id=22216
--- Comment #9 from Eric Pouech eric.pouech@orange.fr 2012-02-25 14:33:13 CST --- see comment #6 <g> A+
http://bugs.winehq.org/show_bug.cgi?id=22216
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |d967484ecc1f6a8c4f84b9d04a6 | |30c566d7c11ae
http://bugs.winehq.org/show_bug.cgi?id=22216
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #10 from Alexandre Julliard julliard@winehq.org 2012-03-02 13:02:31 CST --- Closing bugs fixed in 1.4-rc6.