[Issue 10344] Exiting _Dmain should flush all FILE*s and return nonzero on failure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 17 23:32:11 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10344


Lionello Lunesu <lio+bugzilla at lunesu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lio+bugzilla at lunesu.com


--- Comment #17 from Lionello Lunesu <lio+bugzilla at lunesu.com> 2013-06-17 23:32:08 PDT ---
Adding

    if (fflush(null) != 0)
            throw new Error("write error");

in druntime/src/rt/dmain2.d line 621, between rt_moduleDtor() and gc_term(),
seems to work:

$ ./helloworld 1</dev/null
object.Error: write error
----------------
5   hw                                  0x0000000108047755 extern (C) int
rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void
tryExec(scope void delegate()) + 45
6   hw                                  0x0000000108047709 _d_run_main + 457
7   hw                                  0x0000000108047538 main + 20
8   libdyld.dylib                       0x00007fff8e6107e1 start + 0
9   ???                                 0x0000000000000001 0x0 + 1
----------------

But the question is: what to throw? 

Unfortunately ErrnoException is in phobos, not in druntime. We could move it to
druntime (adding an alias for backcompat.) Moving it would not introduce any
additional dependencies to druntime.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list