#2363: getChar cannot be interrupted with -threaded
----------------------------+-----------------------------------------------
Reporter: simonmar | Owner:
Type: bug | Status: new
Priority: high | Milestone: 6.10 branch
Component: libraries/base | Version: 6.8.2
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
----------------------------+-----------------------------------------------
Comment (by simonmar):
Replying to [comment:3 judah]:
> I think you can prevent that race by calling `hGetBufNonBlocking`, and
retrying if it doesn't read a character
Ironically enough, `hGetBufNonBlocking` suffers from similar problems. As
far as I know it's impossible to implement in a completely race-free way
without using `O_NONBLOCK`, because you have to make two system calls:
first `select()` then `read()`, and someone else could `read()` between
those two. Fortunately GHC almost avoids the race by holding the `Handle`
lock, which is ok as long as all clients are using `Handles` instead of
raw FDs.
Anyway, I have a fix that I'm testing now; it's along the same lines as
your suggestion (call `select()` first, then `read()`).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2363#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs