terminateProcess

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Thu May 17 10:38:53 EDT 2007


according to documentation of System.Process.terminateProcess,
"This function should not be used under normal circumstances."
Well, then what function then *should* be used normally?

I have the following code in a multithreaded Haskell program,
which does not work (if this thread is killed,
the external process keeps running after the Haskell program exits)

        bracket
            ( System.Process.runCommand cmd )
	    ( terminateProcess p	    )
	    ( polling_waitForProcess )

It took me a while to figure out why "waitForProcess" here
does not work: Control.Concurrent.throwTo says
"If the target thread is currently making a foreign call, then the
exception will not be raised (and hence throwTo will not return
until the call has completed.") That's why I defined

 	let polling_waitForProcess p = do
                me <- getProcessExitCode p
		case me of
		    Just e -> return ()
		    Nothing -> do
		        threadDelay ( 10^5 )
			polling_waitForProcess p

any hints appreciated, J.W.


More information about the Libraries mailing list