runInteractiveProcess is broken

Peter Simons simons at cryp.to
Tue Oct 26 14:00:13 EDT 2004


Neither of these functions returns the return code of the
external process as promised:

  import System.IO hiding ( catch, try )
  import System.Process
  import Control.Concurrent

  sleep :: Int -> IO ()
  sleep n = threadDelay (abs(n) * 1000000)

  test1 :: IO ()
  test1 = do
    (_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["1"] Nothing Nothing
    sleep 5
    rc <- waitForProcess pid
    print rc

  -- *Main> test1
  -- *** Exception: waitForProcess: does not exist (No child processes)

  test2 :: IO ()
  test2 = do
    (_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["1"] Nothing Nothing
    sleep 5
    rc <- getProcessExitCode pid
    print rc

  -- *Main> test2
  -- Nothing

I'm using the ghc from CVS-HEAD on Linux/x86.

Peter



More information about the Glasgow-haskell-users mailing list