From c07525ac4692a2ee9c76bd0bd53c195c8164480f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 5 Aug 2025 22:04:11 +0200 Subject: Close handles created for spawned processes --- src/Process.hs | 7 ++++--- src/Script/Shell.hs | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Process.hs b/src/Process.hs index 31641c9..8ea345d 100644 --- a/src/Process.hs +++ b/src/Process.hs @@ -85,9 +85,10 @@ outProc otype p line = outLine otype (Just $ textProcName $ procName p) line lineReadingLoop :: MonadOutput m => Process -> Handle -> (Text -> m ()) -> m () lineReadingLoop process h act = liftIO (tryIOError (T.hGetLine h)) >>= \case - Left err - | isEOFError err -> return () - | otherwise -> outProc OutputChildFail process $ T.pack $ "IO error: " ++ show err + Left err -> do + when (not (isEOFError err)) $ do + outProc OutputChildFail process $ T.pack $ "IO error: " ++ show err + liftIO $ hClose h Right line -> do act line lineReadingLoop process h act diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs index 9bbf06c..95d4fe4 100644 --- a/src/Script/Shell.hs +++ b/src/Script/Shell.hs @@ -69,6 +69,10 @@ spawnShell procNode procName script = do ( herr, pstderr ) <- liftIO $ createPipe procHandle <- fmap (Right . (, statusVar)) $ forkTestUsing forkOS $ do executeScript procNode procName statusVar pstdin pstdout pstderr script + liftIO $ do + hClose pstdin + hClose pstdout + hClose pstderr let procKillWith = Nothing let process = Process {..} -- cgit v1.2.3