[Haskell-cafe] Protecting against main thread exit

Roman Cheplyaka roma at ro-che.info
Sat Feb 15 21:53:33 UTC 2014


When using forkFinally or bracket, I like to have the guarantee that the
cleanup action will be executed regardless of how the action or thread
is terminated — normally or via an exception.

Of course, all guarantees are off when dealing with SIGKILL or power
reset, but there's one other annoying exception (no pun intended) — when
the main thread terminates, all other threads are silently shut down,
without any chance to clean up.

Why is it done that way? Why not kill them with an async exception
instead? That would be a more uniform behavior.

Are there any good ways to protect again the main thread exit?

(Note that I'm talking about a library, so I can't have direct
control over what's going on in the main thread.)

Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140215/fa2713ed/attachment.sig>


More information about the Haskell-Cafe mailing list