Skip to content

runProcess doesn't close handles?

The documentation for runProcess says: "Any Handles
passed to runProcess are placed immediately in the
closed state, so may no longer be referenced by the
Haskell process." But

test =
  do
    h <- openFile "output" WriteMode
    ph <- runProcess "/bin/ls" [] Nothing Nothing
              Nothing (Just h) Nothing
    waitForProcess ph

main = test >> test >> return ()

aborts with "output: openFile: resource busy (file is
locked)" on the second call to test whereas 

test =
  do
    h <- openFile "output" WriteMode
    ph <- runProcess "/bin/ls" [] Nothing Nothing
              Nothing (Just h) Nothing
    hClose h
    waitForProcess ph

main = test >> test >> return ()

works fine.
Trac metadata
Trac field Value
Version 6.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
Component libraries/base
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