[Issue 2545] New: write(f)(ln) throws StdioException("Bad file descriptor") when no console is available

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 29 07:29:15 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2545

           Summary: write(f)(ln) throws StdioException("Bad file
                    descriptor") when no console is available
           Product: D
           Version: 2.022
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: 2korden at gmail.com


It throws an exception at first call to flush when no stdout is a available
(e.g. code compiled for SUBSYSTEM WINDOWS) and it causes some problems for GUI
apps. I believe it should fail immediately (at the very first call to write) or
(preferably) never fail at all. Otherwise, it leads to problem that are hard to
track (e.g. all the unittests pass, but an application fails silently with no
reason after a few hours of execution). I think its behavior should be close to
printf which suppresses an error and goes on.

Test code:

import std.stdio;

void main()
{
    while(true) {
        //printf("!"); // works forever
        write("!");    // fails at first call to flush
    }
}


-- 



More information about the Digitalmars-d-bugs mailing list