#14503: Killing a thread will block if there is another process reading from a handle -------------------------------------+------------------------------------- Reporter: dnadales | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.0.2 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Here is an complete all-Haskell repro, {{{#!hs -- Server.hs import System.IO import Network import Control.Monad import Control.Concurrent main = withSocketsDo $ do sock <- listenOn $ PortNumber 9090 (h, _, _) <- accept sock forever $ do threadDelay 100000 putStrLn "Trying to read something" s <- hGetLine h putStrLn $ "Got "++s }}} {{{#!hs -- Client.hs import Network import System.IO import Control.Concurrent main = readWithinNSecs readWithinNSecs :: IO () readWithinNSecs = withSocketsDo $ do h <- connectTo "localhost" (PortNumber 9090) hSetBuffering h NoBuffering readerTid <- forkIO $ reader h threadDelay $ 2 * 10^6 putStrLn "Killing the reader" killThread readerTid putStrLn "Reader thread killed" where reader h = do line <- hGetLine h putStrLn $ "Got " ++ line }}} Expected output (as seen on Debian 9 with GHC 8.2.2), {{{ $ ghc Server.hs $ ghc Client.hs $ ./Server & ./Client Trying to read something Killing the reader Reader thread killed Server: <socket: 4>: hGetLine: end of file }}} Observed output (on Windows 10 with 64-bit GHC 8.2.1), {{{ $ ghc Server.hs $ ghc -threaded Client.hs $ ./Server & ./Client Killing the reader Reader thread killed Trying to read something server.exe: <socket: 372>: hGetLine: failed (Unknown error) }}} Seems like things are working as expected. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14503#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler