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).
Comment #6 by hsteoh — 2014-08-03T01:22:00Z
Comment #7 by hsteoh — 2014-08-03T01:23:55Z
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
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/bc353da47cb125401633abfd2194a3ba596976da fix Issue 13241 - [REG2.067a] writeln no longer flushes stdout https://github.com/D-Programming-Language/phobos/commit/46193e50462f1b2c2b759a60edf399d075d7c4ee Merge pull request #2436 from CyberShadow/fix13241 fix Issue 13241 - [REG2.067a] writeln no longer flushes stdout
Comment #11 by github-bugzilla — 2014-08-19T22:28:24Z
Commit pushed to revert-2436-fix13241 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/0198a2ee58accd7bc367fb7f3ebe84a462e93e6b Revert "fix Issue 13241 - [REG2.067a] writeln no longer flushes stdout"
Comment #12 by bugzilla — 2014-08-19T22:29:46Z
I believe this is the wrong fix, as outlined in the PR.
Comment #13 by bugzilla — 2014-08-19T23:28:44Z