[GHC] #9292: Race condition when multiple threads wait for a process

#9292: Race condition when multiple threads wait for a process -------------------------------------+------------------------------------- Reporter: snoyberg | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: libraries/process | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Consider the following code: {{{ import System.Process import Control.Concurrent.Async main :: IO () main = do (_, _, _, ph) <- createProcess $ shell "sleep 1" let helper i = do ec <- waitForProcess ph print (i :: Int, ec) ((), ()) <- concurrently (helper 1) (helper 2) return () }}} If I compile with the single threaded runtime, I get the output {{{ (2,ExitSuccess) (1,ExitSuccess) }}} But when compiling with the multithreaded runtime, I get: {{{ bin: waitForProcess: does not exist (No child processes) }}} If you need to wait for a process from multiple threads, you can do so now by having a dedicated wait thread which writes to an MVar or TMVar, but the current default behavior can be surprising. I discussed this in a [http://www.yesodweb.com/blog/2014/07/rfc-new-data- conduit-process blog post], and there was some [http://www.reddit.com/r/haskell/comments/2abmwu/rfc_new_dataconduitprocess/c... conversation on Reddit]. At the least, I think we need better documentation, but if there's a better solution, that would be best. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9292 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC