Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,944
    • Issues 4,944
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 453
    • Merge requests 453
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8684
Closed
Open
Created Jan 19, 2014 by Niklas Hambüchen@nh2Reporter

hWaitForInput cannot be interrupted by async exceptions on unix

http://hackage.haskell.org/package/base-4.6.0.1/docs/System-Timeout.html

claims that timeout can interrupt hWaitForInput, but in fact that's false (e.g. mentioned in #7353 (closed)#ticket:8684#comment:78734).

-- 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 hWaitForInput.

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 unsafe unsafe_fdReady.

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 interruptible one.

Is that true?

If not, it's a documentation bug in timeout at least.

Also, does interruptible, apart from allowing the function to be interrupted, behave more like safe or unsafe?

Edited Mar 10, 2019 by Niklas Hambüchen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking