Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly close stderr and stdout handles to stop leaking fds #113

Merged
merged 2 commits into from
Sep 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion funflow/src/Control/Funflow/External/Executor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import System.IO (Handle, IOMode (..),
import System.Posix.Env (getEnv)
import System.Posix.User
import System.Process
import GHC.IO.Handle (hClose)

data ExecutionResult =
-- | The result already exists in the store and there is no need
Expand Down Expand Up @@ -121,6 +122,8 @@ execute store td = logError $ do
-- Error output should be displayed on our stderr stream
withFollowOutput $ do
exitCode <- waitForProcess ph
hClose hErr
hClose hOut
end <- getTime Monotonic
case exitCode of
ExitSuccess -> do
Expand Down Expand Up @@ -241,4 +244,6 @@ withFollowFile infile outhandle action = do
else do
BS.hPut outhandle some
loop
snd <$> concurrently (tryIO loop) (action <* putMVar mv ())
res <- snd <$> concurrently (tryIO loop) (action <* putMVar mv ())
hClose inhandle
return res