[GHC] #8433: forkProcess masks async exceptions inside the child process

GHC ghc-devs at haskell.org
Fri Nov 8 11:15:09 UTC 2013


#8433: forkProcess masks async exceptions inside the child process
-----------------------------------+------------------------------------
        Reporter:  joeyh           |            Owner:
            Type:  bug             |           Status:  new
        Priority:  normal          |        Milestone:
       Component:  libraries/unix  |          Version:  7.6.3
      Resolution:                  |         Keywords:
Operating System:  Linux           |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown    |       Difficulty:  Unknown
       Test Case:                  |       Blocked By:
        Blocking:                  |  Related Tickets:
-----------------------------------+------------------------------------

Comment (by hvr):

 Potential fix:

 {{{#!hs
 forkProcess :: IO () -> IO ProcessID
 forkProcess action = do
   -- wrap action to re-establish caller's masking state, as
   -- 'forkProcessPrim' starts in 'MaskedInterruptible' state by
   -- default; see also #1048
   mstate <- getMaskingState
   let action' = case mstate of
           Unmasked              -> unsafeUnmask action
           MaskedInterruptible   -> action
           MaskedUninterruptible -> uninterruptibleMask_ action

   bracket
     (newStablePtr (runIO action'))
     freeStablePtr
     (\stable -> throwErrnoIfMinus1 "forkProcess" (forkProcessPrim stable))
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8433#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list