Skip to content

Commit

Permalink
Merge pull request #19 from msakai/fix-deadlock
Browse files Browse the repository at this point in the history
Fix deadlock in Numeric.Optimization.MIP.Internal.ProcessUtil
  • Loading branch information
msakai committed Feb 27, 2021
2 parents cf6f494 + 7d7eb35 commit 9a46bcb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MIP/src/Numeric/Optimization/MIP/Internal/ProcessUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ runProcessWithOutputCallback cmd args input putMsg putErr = do
, std_out = CreatePipe
, std_err = CreatePipe
}
hSetBuffering outh LineBuffering
hSetBuffering errh LineBuffering

req <- newEmptyTMVarIO
let f act = atomically (putTMVar req act)
m1 = forever (hGetLine outh >>= \s -> f (putMsg s))
Expand All @@ -59,8 +62,6 @@ runProcessWithOutputCallback cmd args input putMsg putErr = do
-- hClose performs implicit hFlush, and thus may trigger a SIGPIPE
ignoreSigPipe $ hClose inh

hSetBuffering outh LineBuffering
hSetBuffering errh LineBuffering
let loop = join $ atomically $ msum $
[ do act <- takeTMVar req
return $ act >> loop
Expand Down

0 comments on commit 9a46bcb

Please sign in to comment.