Ticket #4119 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

File buffering isn't flushed at exit

Reported by: EyalLotem Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 6.12.1
Keywords: file buffers Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Incorrect result at runtime Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

In C, there's an atexit handler to fflush all FILE* files.

In most other environments (e.g: Python files), file buffers are flushed in a graceful exit. With GHC 6.12.1, they aren't.

Attachments

testwrite.hs Download (133 bytes) - added by EyalLotem 3 years ago.
Small program to reproduce the bug

Change History

Changed 3 years ago by EyalLotem

Small program to reproduce the bug

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to invalid

This is an example of how finalizers aren't guaranteed to be run. If you use withFile then the handle will be closed and the data written, even if there is an exception:

import System.IO

main = withFile "test.txt" WriteMode $ \h ->
       hPutStrLn h "Hello world"
Note: See TracTickets for help on using tickets.