Skip to content

readProcessWithExitCode leaks when the program does not exist

import Control.Monad
import System.Process
import qualified Control.Exception as C

try' :: IO a -> IO (Either C.SomeException a)
try' = C.try

main = replicateM_ 1000 $ do
  try'           (readProcessWithExitCode "doesnotexist" [] "")
  print =<< try' (readProcessWithExitCode "/bin/echo" ["it works"] "")

This eventually runs out of file descriptors and fails to start the existing process.

Tested with process 1.2.0.0 and GHC 7.8.2 on OS X

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/process
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information