digitalmars.D.bugs - [Issue 2186] New: Out of order in stdout
- d-bugmail puremagic.com (35/35) Jun 30 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2186
- d-bugmail puremagic.com (13/13) Jun 30 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2186
- d-bugmail puremagic.com (6/8) Jun 30 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2186
http://d.puremagic.com/issues/show_bug.cgi?id=2186 Summary: Out of order in stdout Product: D Version: 1.024 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: mihail.zenkov gmail.com Simple test case: import std.stdio; import std.process; void main() { writefln("line1"); system("echo line2"); writefln("line3"); system("echo line4"); } line1 line2 line3 line4 All fine. But when i try redirect it to file or other process, i have: line2 line4 line1 line3 gdc (GCC) 4.1.2 20070214 ( gdc 0.24, using dmd 1.024) --
Jun 30 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2186 andrei metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID "It's not a bug, it's a feature". It's simple, really. The pipe transforms stdio for the D program from line-buffered to block-buffered. The writefln call does not flush the stream, and that's about what happens. The same happens in a C program using printf and system. To fix, you may want to insert calls to fflush(stdout) after the writes. --
Jun 30 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2186"It's not a bug, it's a feature". It's simple, really. The pipe transforms stdio for the D program from line-buffered to block-buffered. The writefln call^^^^^ I meant stdout not stdio. --
Jun 30 2008