Errors when shutting down the event manager loop
As explained in this thread on the GHC list I use the GHC event manager in my usb library. I create my own EventManager and start a thread which runs the event manager loop. When the library is finalized I automatically shutdown the loop. However this causes error messages from the RTS to be printed.
The following program shows the problem in isolation:
import Control.Concurrent
import GHC.Event
main = do
em <- new
tid <- forkIO $ loop em
threadDelay 2000000
shutdown em -- Note that 'killThread tid' has the same effect.
threadDelay 2000000
Make sure to build it with -threaded enabled:
$ ghc -threaded --make eventManagerBug.hs
Running it gives the following errors:
$ ./eventManagerBug
example: ioManagerWakeup: write: Bad file descriptor
example: ioManagerDie: write: Bad file descriptor
Note that these errors are printed in the ioManagerWakeup function in rts/posix/Signals.c.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.2.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | bos@mailrank.com, johan.tibell@gmail.com |
| Operating system | |
| Architecture |