Fail: thread killed

Marcin 'Qrczak' Kowalczyk
6 Mar 2001 20:12:51 GMT

I think I have raised the issue some time ago, but don't remember
why it hasn't been solved as I would like to.

Currently a thread which is killed displays Fail: thread killed,
e.g. in the following program:

import Concurrent
main:: IO ()
main = do
    t <- forkIO (threadDelay 1000000)
    threadDelay 500000
    killThread t
    threadDelay 500000

Since the very purpose of killThread is to kill the damn thread,
I find it inconvenient to have to wrap any thread which is supposed
to be killable with Exception.catch to avoid the message. Worse:
it should use block and unblock, otherwise there is a small window
where killing the thread will still display the message.

I can probably agree that other kinds of exceptions are displayed;
maybe the programmer didn't know that exceptions are being thrown and
wants the diagnostic. It implies that any well-written code should
catch exceptions in all threads it creates (unless he is sure that the
code will not throw exceptions), since there shouldn't be compiler's
error output from a correct program. Not nice but I can live with that.

Should asynchronous exceptions be really displayed in threads other
than the main thread? IMHO not.

 __("<  Marcin Kowalczyk *
  ^^                      SYGNATURA ZASTĘPCZA