I am not well-versed in Haskell-specific multi-threading, but usually there is a better way to do what you want that does not involve killing threads (which in most cases is bad idea.)
For example, using non-blocking IO and e.g. a synchronized condition variable; hWaitForInput might work in your case, or something like the following: http://hpaste.org/52742
Nevertheless, as a guess, I think you may want to try using closeFdWith, perhaps combined with a call to threadWaitRead before actually calling hGetLine. The wrinkle is that those operate on file descriptors instead of handles, but there are fdToHandle/mkHandleFromFD to bridge the gap.
On Sat, Apr 28, 2012 at 2:23 PM, H. M. <[hidden email]> wrote:
> There are two threads, one which is waits on input via
> and another, which should terminate this thread or close this handle.
> as well as
> doesn't seem to work, caused by the fact, that the thread is blocked until input
> is availiable.
What OS? GHC currently doesn't have proper IO manager support for
Windows. On Windows, IO is performed through FFI calls. An FFI call
masks asynchronous exceptions (C code generally doesn't expect to be
interrupted at arbitrary points in time). If another thread tries to
`killThread` the thread waiting for input, the exception will not be
received until the FFI call completes. This means both threads will