./T and ./T >& log

Simon Marlow marlowsd at gmail.com
Tue Feb 24 08:36:25 EST 2009


Malcolm Wallace wrote:
> Simon Marlow <marlowsd at gmail.com> wrote:
> 
>> stdout should be flushed when the program exits, regardless of whether
>> it  exits as a result of a clean exit or an exception.  I've just
>> checked the  code, and that's certainly what is supposed to happen. 
>> If anyone has  evidence to the contrary, please submit a bug report!
> 
> I believe flushing of file handles on program exit is handled by
> finalizers attached to the handle.  Until recently, ghc did not
> guarantee that any finalizer would ever run.

Not exactly.

There's a top-level exception handler that flushes stdout and stderr, so 
they always get flushed on exit (or at least, they are supposed to).  Look 
in base:GHC.TopHandler for the code.

Other handlers will only get flushed if their finalizers run, and nothing 
has changed here: we now guarantee execution of C finalizers, but that 
doesn't apply to the finalizers for Handles, which are Haskell code.

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list