@@ -518,7 +518,7 @@ cleanupNormal (_, _, _, procHandle) = do
518518-- still hanging around.
519519cleanupException ::
520520 (Maybe Handle , Maybe Handle , Maybe Handle , ProcessHandle ) -> IO ()
521- cleanupException (Just stdinH, Just stdoutH , stderrMaybe, ph) = do
521+ cleanupException (stdinMaybe, stdoutMaybe , stderrMaybe, ph) = do
522522 -- Send a SIGTERM to the process
523523#ifdef USE_NATIVE
524524 terminate ph
@@ -529,8 +529,8 @@ cleanupException (Just stdinH, Just stdoutH, stderrMaybe, ph) = do
529529 -- Ideally we should be closing the handle without flushing the buffers so
530530 -- that we cannot get a SIGPIPE. But there seems to be no way to do that as
531531 -- of now so we just ignore the SIGPIPE.
532- hClose stdinH `catch` eatSIGPIPE
533- hClose stdoutH
532+ whenJust ( \ stdinH -> hClose stdinH `catch` eatSIGPIPE) stdinMaybe
533+ whenJust hClose stdoutMaybe
534534 whenJust hClose stderrMaybe
535535
536536 -- Non-blocking wait for the process to go away
@@ -553,7 +553,6 @@ cleanupException (Just stdinH, Just stdoutH, stderrMaybe, ph) = do
553553 _ -> False
554554
555555 eatSIGPIPE e = unless (isSIGPIPE e) $ throwIO e
556- cleanupException _ = error " cleanupProcess: Not reachable"
557556
558557-- | Creates a system process from an executable path and arguments. For the
559558-- default attributes used to create the process see 'mkConfig'.
@@ -873,8 +872,7 @@ toChunksWith modifier path args =
873872
874873 where
875874
876- run (_, Just stdoutH, _, _) = toChunksClose stdoutH
877- run _ = error " toChunksWith: Not reachable"
875+ run (_, stdoutMaybe, _, _) = maybe Stream. nil toChunksClose stdoutMaybe
878876
879877-- | @toBytesEither path args@ runs the executable at @path@ using @args@ as
880878-- arguments and returns the output of the process as a stream of 'Either'
0 commit comments