> causes the entire program to crash.  (Not just the thread 
> that is doing the
> threadWaitRead.)  Is this not a little drastic?  To run the 
> attached code use
> 
> ghc -syslib posix -syslib concurrent -cpp ThreadWaitFail.hs -o TWF
> ./TWF

You're right, this is a bug.  But I'm not sure what to do about it: firstly,
select returns EBADF with no indication of which particular fd is bad.  

And secondly, should threadWaitRead just return, or should it raise an
exception of some kind?  If it just returns, there's a good chance that the
application will shortly attempt to read something from the fd and get an
error.  So one possibility is to just wake up all the threads currently
blocked on I/O in the hope that the one with the bogus fd will soon die.

The only other alternative is to attempt to discover which fd is bogus by
testing each one of them with an individual select() or fcntl() (or
something).  This is painful.

Any other ideas?

Cheers,
        Simon

Reply via email to