|
RE: hClose non-terminating: msg#00009lang.haskell.glasgow.bugs
> I have a problem with a handle for which hClose does not > terminate. Unfortunately > it's too much work for me to narrow it down now, but perhaps > it can be worked out > from these facts? > (1) it's a socket connection. > (2) it has BlockBuffering (Just 4096) set. > (3) it is possible that another thread is simultaneously > trying to read from it. > (4) hFlush on the same handle terminates. > (5) if I remove the hClose the program terminates (presumably > closing the connection) successfully. Sorry for the delay in replying. I think this is "expected behaviour" (or possibly a known bug). You can demonstrate it like this: main = do forkIO (getChar >> return ()) yield hClose stdin The thread reading from the handle has a lock on it, so that hClose has to wait before it can gain access to the handle to close it. What would you like to happen in this case? I guess getChar could be given an exception if the handle was closed underneath it. The problem is that releasing the lock in the middle of getChar while it waits for input is quite awkward to implement, and doing it in the middle of getLine is even worse. hFlush on the handle terminates because that only acts on the write side of the handle, which has a separate lock from the read side. My feeling is that this would be a pain to fix. Can you work around it? Cheers, Simon
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: strange difference between old and hierachical module names, Simon Peyton-Jones |
|---|---|
| Next by Date: | [ ghc-Bugs-821047 ] ghci --help produces help for ghc, SourceForge.net |
| Previous by Thread: | Slight doc typos, Juanma Barranquero |
| Next by Thread: | Re: hClose non-terminating, George Russell |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |