Skip to content

Commit

Permalink
Be even more careful about possibly-closed handles
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar committed Jul 19, 2023
1 parent f9b214d commit cb0cb26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Reflex/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ createProcessBufferingInput readBuffer writeBuffer spec config = do
where
input :: ProcessHandle -> Handle -> IO (SendPipe ByteString -> IO ())
input ph h = do
H.hSetBuffering h H.NoBuffering
H.hIsOpen h >>= \open -> if open then H.hSetBuffering h H.LineBuffering else return ()
void $ liftIO $ async $ race_ (waitForProcess ph) $ fix $ \loop -> do
newMessage <- readBuffer
open <- H.hIsOpen h
Expand All @@ -154,7 +154,7 @@ createProcessBufferingInput readBuffer writeBuffer spec config = do
SendPipe_EOF -> H.hClose h
return writeBuffer
output h trigger = do
H.hSetBuffering h H.LineBuffering
H.hIsOpen h >>= \open -> if open then H.hSetBuffering h H.LineBuffering else return ()
pure $ fix $ \go -> do
open <- H.hIsOpen h
when open $ do
Expand Down

0 comments on commit cb0cb26

Please sign in to comment.