Bug 13241 – [REG2.067a] writeln no longer flushes stdout
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2014-08-02T02:04:00Z
Last change time
2014-08-20T00:30:16Z
Keywords
pull
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2014-08-02T02:04:01Z
Windows test case:
///////////////// test.d /////////////////
import std.stdio;
extern(System) void ExitProcess(int code);
void main()
{
writeln("Test!");
ExitProcess(0);
}
//////////////////////////////////////////
Before, the line showed up immediately after the writeln.
This bug causes issues for programs that display their status to stdout/stderr.
Introduced in https://github.com/D-Programming-Language/phobos/pull/2334
Comment #1 by hsteoh — 2014-08-02T22:07:39Z
According to the comments on github, this only happens with the DMC runtime? What would be the suggested fix? I'm not very familiar with how C stdio interacts with the Windows runtime environment.
Comment #2 by hsteoh — 2014-08-02T22:25:17Z
Random thought: would it help if std.stdio registered an atexit() function that flushes stdout? Could somebody try this on Windows? (I don't have a Windows dev environment.)
Comment #3 by dlang-bugzilla — 2014-08-02T23:19:13Z
No, and that misses the point of this bug request. Streams are already flushed on normal process termination. The problem is that the lines are not shown on the screen instantly, which means that programs that display their progress to the screen will have laggy output.
Comment #4 by hsteoh — 2014-08-03T01:16:45Z
Oh. So it's just a matter of flushing after each line? That's not hard to do.
Comment #5 by dlang-bugzilla — 2014-08-03T01:18:36Z
Yes, though note that the previous behavior was to flush only when writing to screen. When the program output is redirected to a file, AFAIK the streams were flushed only explicitly (or when the buffer is full).
Not sure if this is the right fix, since technically it should be a matter of setting up stdout so that the flushing is done at OS level.
Comment #8 by dfj1esp02 — 2014-08-04T05:03:28Z
My guess is that on linux and ms fwrite detects line break and flushes the buffer, while snn fwrite writes in binary mode. It can also manifest in not translating \n to \r\n on windows.
Comment #9 by k.hara.pg — 2014-08-07T12:43:50Z
This is git-head only regression, and does not occur with 2.066-rc1.
Comment #10 by github-bugzilla — 2014-08-19T15:48:39Z