How do you get the process id out of the ProcessHandle in Win XP?

John Vogel jpvogel1 at
Wed Dec 19 21:59:58 EST 2007

Here is what I have tried:

module Main where

import System.Process   -- using   runInteractiveProcess
import System.Posix.Types
import System.Process.Internals
import Control.Concurrent.MVar

main = do
(input,output,err,ph) <- runInteractiveProcess calc.exe" ([]) Nothing
p <- Main.getPID ph
putStrLn $ show p --- The output

getPID :: ProcessHandle -> IO CPid
getPID (ProcessHandle p) = do
(OpenHandle pp) <- takeMVar p
return (toPID pp)

toPID :: PHANDLE -> CPid
toPID ph = toEnum $ fromEnum ph

 But the CPid always returns some const value (like 1904 in cygwin; 1916 in

I think, I saw that CPid was a newtype of Ptr ()

So, currently I need to get the process id from CPid or something else.

All help is appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list