Thread overview |
---|
June 30, 2008 [Issue 2186] New: Out of order in stdout | ||||
---|---|---|---|---|
| ||||
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"); } # gdc test.d -o test # ./test line1 line2 line3 line4 All fine. But when i try redirect it to file or other process, i have: # ./test | cat line2 line4 line1 line3 gdc (GCC) 4.1.2 20070214 ( gdc 0.24, using dmd 1.024) -- |
July 01, 2008 [Issue 2186] Out of order in stdout | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2186 andrei@metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from andrei@metalanguage.com 2008-06-30 21:29 ------- "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. -- |
July 01, 2008 [Issue 2186] Out of order in stdout | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2186 ------- Comment #2 from andrei@metalanguage.com 2008-06-30 21:30 ------- (In reply to comment #1) > "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. -- |
Copyright © 1999-2021 by the D Language Foundation