RE: runInteractiveProcess is broken

I can't repeat this, it works here: *Main> test1 ExitSuccess *Main> test2 Just ExitSuccess (after changing /usr/bin/sleep to /bin/sleep). The only thing I can think of is that you somehow have a SIGCHLD handler that calls wait(), but I don't see where that can be happening. GHC doesn't have any other mechanism for calling wait(), so I don't understand how the zombies are disappearing before waitForProcess is called. Maybe run it through strace and send us the output? Cheers, Simon On 26 October 2004 19:00, Peter Simons wrote:
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
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Simon Marlow writes:
test1 :: IO () test1 = do (_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["3"] Nothing Nothing sleep 1 rc <- waitForProcess pid print rc
I can't repeat this, it works here: *Main> test1 ExitSuccess *Main> test2 Just ExitSuccess
Maybe run it through strace and send us the output?
I cannot reproduce the error myself anymore! I have no idea what has changed; suddenly 'test1' and 'test2' both work reliably -- whether I catch sigCHLD or not. It used to work only when I did catch the signal. This is really bizarre. The moment I see some strange behavior from these functions again, I'll strace it right away and will come back to the topic. Let's hope it never happens. Thanks for the support everybody! Peter

Hi, When I run the following line in ghci: Prelude System.Process Control.Concurrent System.IO> do { (inp, out, err, ph) <- runInteractiveProcess "cat" [] Nothing Nothing; forkIO (do hPutStr inp "this\nis\na\ntest\n"; hClose inp); waitForProcess ph } ... it doesn't terminate. I'm following the example in the System.Process documentation. But I would think that since I close 'inp', "cat" would terminate. Also, I don't see the expected output. Frederik -- http://ofb.net/~frederik/
participants (3)
-
Frederik Eaton
-
Peter Simons
-
Simon Marlow