hWaitForInput cannot be interrupted by async exceptions on unix
-- import Control.Concurrent import System.IO import System.Timeout main = timeout (1 * 1000000) $ hWaitForInput stdin (5 * 1000)
will not be killed after 1 second, but instead wait for the full 5 seconds timeout passed to
The implementation is
ready at https://downloads.haskell.org/\~ghc/7.6.3/docs/html/libraries/base/src/GHC-IO-FD.html, where we have two foreign calls:
safe fdReady and
The actual C implementation is at https://github.com/ghc/packages-base/blob/52c0b09036c36f1ed928663abb2f295fd36a88bb/cbits/inputReady.c\#L16. It uses
select on Unix, and does check for
EINTR, so I believe that according to http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/ffi.html\#ffi-interruptible both foreign calls can be replaced by a single
Is that true?
If not, it's a documentation bug in
timeout at least.
interruptible, apart from allowing the function to be interrupted, behave more like