X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FProcess.hs;h=d4bc43f7717fb9572d6491902e690bd173577b31;hb=d50c1eee6e446d385357f4d7079d700ed3275d74;hp=fa10b4c8c7e8343736d70f3ca352c54fb07003c8;hpb=42687af2c43217b778a64cf836a4c63a99a5243f;p=haskell-directory.git diff --git a/System/Process.hs b/System/Process.hs index fa10b4c..d4bc43f 100644 --- a/System/Process.hs +++ b/System/Process.hs @@ -167,7 +167,8 @@ runInteractiveProcess1 fun cmd args mb_cwd mb_env = do hndStdInput <- fdToHandle pfdStdInput WriteMode hndStdOutput <- fdToHandle pfdStdOutput ReadMode hndStdError <- fdToHandle pfdStdError ReadMode - return (hndStdInput, hndStdOutput, hndStdError, ProcessHandle proc_handle) + ph <- mkProcessHandle proc_handle + return (hndStdInput, hndStdOutput, hndStdError, ph) foreign import ccall unsafe "runInteractiveProcess" c_runInteractiveProcess @@ -201,8 +202,8 @@ runInteractiveProcess1 fun cmd args workDir env extra_cmdline hndStdInput <- fdToHandle pfdStdInput WriteMode hndStdOutput <- fdToHandle pfdStdOutput ReadMode hndStdError <- fdToHandle pfdStdError ReadMode - return (hndStdInput, hndStdOutput, hndStdError, - ProcessHandle proc_handle) + ph <- mkProcessHandle proc_handle + return (hndStdInput, hndStdOutput, hndStdError, ph) foreign import ccall unsafe "runInteractiveProcess" c_runInteractiveProcess @@ -235,7 +236,8 @@ fdToHandle pfd mode = do waitForProcess :: ProcessHandle -> IO ExitCode -waitForProcess (ProcessHandle handle) = do +waitForProcess ph = do + handle <- getProcessHandle ph code <- throwErrnoIfMinus1 "waitForProcess" (c_waitForProcess handle) if (code == 0) then return ExitSuccess @@ -253,7 +255,8 @@ waitForProcess (ProcessHandle handle) = do -- On Windows systems, the Win32 @TerminateProcess@ function is called, passing -- an exit code of 1. terminateProcess :: ProcessHandle -> IO () -terminateProcess (ProcessHandle pid) = +terminateProcess ph = do + pid <- getProcessHandle ph throwErrnoIfMinus1_ "terminateProcess" (c_terminateProcess pid) -- ---------------------------------------------------------------------------- @@ -267,7 +270,8 @@ Subsequent calls to @getProcessExitStatus@ always return @'Just' 'ExitSuccess'@, regardless of what the original exit code was. -} getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode) -getProcessExitCode (ProcessHandle handle) = +getProcessExitCode ph = do + handle <- getProcessHandle ph alloca $ \pExitCode -> do res <- throwErrnoIfMinus1 "getProcessExitCode" (c_getProcessExitCode handle pExitCode) code <- peek pExitCode