Thread overview | |||||
---|---|---|---|---|---|
|
June 11, 2013 [Issue 10328] New: std.stdio.write doesn't throw on failure | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10328 Summary: std.stdio.write doesn't throw on failure Product: D Version: D2 Platform: All OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: Jesse.K.Phillips+D@gmail.com --- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2013-06-10 19:48:24 PDT --- Running a simple hello world program import std.stdio; void main() { writeln("Hello World"); write("Hello World"); } And executing where /dev/null is redirected as input to stdout (causing an invalid fd) $ ./hello 1</dev/null http://forum.dlang.org/post/egmumvacbiflshtjofay@forum.dlang.org Expected to see an exception thrown. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2013 [Issue 10328] std.stdio.write doesn't throw on failure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=10328 Infiltrator <lt.infiltrator@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lt.infiltrator@gmail.com --- Comment #1 from Infiltrator <lt.infiltrator@gmail.com> 2013-06-10 21:15:15 PDT --- For comparison, here's the the same thing done to cat: $ cat 1</dev/null test cat: write error: Bad file descriptor -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2013 [Issue 10328] std.stdio.write doesn't throw on failure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=10328 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution| |INVALID --- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2013-06-11 10:29:26 PDT --- This is intended behavior. std.stdio.stdout is buffered, and the lines in your code have not attempted to write to the file descriptor yet. If you add: std.stdio.stdout.flush(); then it fails with an exception as expected. Note that C (and by using C's stdio as it's base, D also) decides whether to flush after newline depending on whether the file descriptor is a console or not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation