Roman Cheplyaka | 15 Feb 22:53 2014

Protecting against main thread exit

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

Haskell-Cafe mailing list
Haskell-Cafe <at>