Skip to content

runProcess hangs with duplicate handles

runProcess doesn't seem to allow the same handle to be
used for redirecting stdout and stderr. Thus,

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

hangs in ghci and aborts with "thread blocked
indefinitely" if compiled.   This isn't documented and
I hope this is not the intended behaviour as
redirecting stdout and stderr (and stdin in the case of
ptys) to the same file/pipe is quite common.

System is Linux 2.4.20-8 #1 Thu Mar 13 17:54:28 EST
2003 i686
ghc is vanilla 6.4
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