[Bug 22216] New: Problem with freopen("CONOUT$", "w", stdout);

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Mar 30 19:28:01 CDT 2010


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 at winehq.org
        ReportedBy: terra at 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.)

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list