[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 13:31:36 PDT 2013


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



--- Comment #14 from Andrei Alexandrescu <andrei at erdani.com> 2013-06-17 13:31:35 PDT ---
(In reply to comment #12)
> (In reply to comment #11)
> > The program has made a decision that assumes writes to stdout, if any, have
> > succeeded.
> 
> You seem to be ignoring the use case.

Apparently you are ignoring my reply to it, which addressed it directly
acknowledging that the success of producing stdout output does not define the
success of the program.

>  The return code is based on database
> update success, not stdout success.

I understood that the first time.

> In fact, I can write the code in such a
> way that specifically ignores stdout failures, yet still have this come up.

No, if you flush (and catch) at the end of the program you're in good shape.
Consider:

import std.stdio;
int main()
{
    writeln("test");
    fflush(null);
    return fflush(null);
}

This will never fail. The first flush fails, but the second does not.

> > > Consider the case where the filesystem driver fails to finish writing the file
> > > after the program exits.  How do we handle that?
> > 
> > That is not under our control.
> 
> None of this is under our control.  It's outside our visibility.  But the
> effect is the same -- data is not written.  We can't say definitively that a D
> program guarantees the data goes to it's final destination.  The error is in
> fact useless because success doesn't guarantee the write occurs.

Untrue. The success guarantees that the program succeeded in passing data
forward to the operating system. Please let's not make this an argument about
the tree in the forest.

D checks all flushes. Consequently it should check the last flush. No two ways
about it. End of story.

> In fact, all a success guarantees is that the program succeeded according to
> it's charter.

That is correct. The problem with ignoring the last flush is that we assume
that the charter of the program is it's okay to produce truncated output.

> I have another compromise that I will post to this bug report separately.

Looking forward to it.

-- 
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