[GHC] #2233: Overhaul System.Process
GHC
ghc-devs at haskell.org
Sat Nov 30 23:03:31 UTC 2013
#2233: Overhaul System.Process
--------------------------------------+------------------------------------
Reporter: simonmar | Owner: simonmar
Type: task | Status: patch
Priority: normal | Milestone: _|_
Component: libraries/process | Version: 6.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
--------------------------------------+------------------------------------
Comment (by Herbert Valerio Riedel <hvr@…>):
In [changeset:"d95a67012ea30b02144d193254d947cdf5400a9d/process"]:
{{{
#!CommitTicketReference repository="process"
revision="d95a67012ea30b02144d193254d947cdf5400a9d"
Be even more careful with the threads that consume output (#2233)
There is a potential deadlock with withCreateProcess in the case that
there's an exception: cleanupProcess will try to hClose the various
handles, but if another thread holds the Handle lock then that hClose
will block.
Takano Akio fixed the main case of this (in patch
32223a9ab174c22e939c81e24b6f48223c7cb020) by terminating the process
(before closing the handles) This works because terminating the process
will eventually cause those other threads to finish and release the
Handle lock, so we can hClose.
However on Unix terminateProcess is not guaranteed to terminate the
process since it uses SIGTERM, which can be handled or ignored. So we
have to separately guarantee that the handles can be hClosed, and the
simplest way to do this is to ensure that the thread reading from the
handles get killed in the case there's an exception.
So we change forkWait to withForkWait that will kill off the thread if
the body gets an exception.
Authored-by: Duncan Coutts <duncan at well-typed.com>
Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2233#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list