[commit: packages/process] master: GH77: restored compatibility. (c3c067b)

git at git.haskell.org git at git.haskell.org
Wed Jul 19 21:18:16 UTC 2017


Repository : ssh://git@git.haskell.org/process

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c3c067be022d192a7599476afd3bed903070b4a1/process

>---------------------------------------------------------------

commit c3c067be022d192a7599476afd3bed903070b4a1
Author: Tamar Christina <tamar at zhox.com>
Date:   Sat Jan 7 11:51:44 2017 +0000

    GH77: restored compatibility.


>---------------------------------------------------------------

c3c067be022d192a7599476afd3bed903070b4a1
 System/Process.hs           | 34 +++++++++++++++++++++-------------
 System/Process/Internals.hs |  8 ++++----
 process.cabal               |  2 +-
 tests/T9775/T9775_fail.hs   |  2 +-
 tests/T9775/T9775_good.hs   |  2 +-
 5 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/System/Process.hs b/System/Process.hs
index f9db2d0..245ad8b 100644
--- a/System/Process.hs
+++ b/System/Process.hs
@@ -192,7 +192,7 @@ createProcess cp = do
   maybeCloseStd (std_in  cp)
   maybeCloseStd (std_out cp)
   maybeCloseStd (std_err cp)
-  return $ unwrapHandles r
+  return r
  where
   maybeCloseStd :: StdStream -> IO ()
   maybeCloseStd (UseHandle hdl)
@@ -230,7 +230,7 @@ withCreateProcess_
   -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> IO a)
   -> IO a
 withCreateProcess_ fun c action =
-    C.bracketOnError (unwrapHandles <$> createProcess_ fun c) cleanupProcess
+    C.bracketOnError (createProcess_ fun c) cleanupProcess
                      (\(m_in, m_out, m_err, ph) -> action m_in m_out m_err ph)
 
 
@@ -269,16 +269,18 @@ cleanupProcess (mb_stdin, mb_stdout, mb_stderr,
 --
 -- @since 1.2.0.0
 spawnProcess :: FilePath -> [String] -> IO ProcessHandle
-spawnProcess cmd args =
-    procHandle <$> createProcess_ "spawnProcess" (proc cmd args)
+spawnProcess cmd args = do
+    (_,_,_,p) <- createProcess_ "spawnProcess" (proc cmd args)
+    return p
 
 -- | Creates a new process to run the specified shell command.
 -- It does not wait for the program to finish, but returns the 'ProcessHandle'.
 --
 -- @since 1.2.0.0
 spawnCommand :: String -> IO ProcessHandle
-spawnCommand cmd =
-    procHandle <$> createProcess_ "spawnCommand" (shell cmd)
+spawnCommand cmd = do
+    (_,_,_,p) <- createProcess_ "spawnCommand" (shell cmd)
+    return p
 
 
 -- ----------------------------------------------------------------------------
@@ -725,8 +727,9 @@ runCommand
   :: String
   -> IO ProcessHandle
 
-runCommand string =
-  procHandle <$> createProcess_ "runCommand" (shell string)
+runCommand string = do
+  (_,_,_,ph) <- createProcess_ "runCommand" (shell string)
+  return ph
 
 
 -- ----------------------------------------------------------------------------
@@ -756,7 +759,8 @@ runProcess
   -> IO ProcessHandle
 
 runProcess cmd args mb_cwd mb_env mb_stdin mb_stdout mb_stderr = do
-  r <- createProcess_ "runProcess"
+  (_,_,_,ph) <-
+      createProcess_ "runProcess"
          (proc cmd args){ cwd = mb_cwd,
                           env = mb_env,
                           std_in  = mbToStd mb_stdin,
@@ -765,7 +769,7 @@ runProcess cmd args mb_cwd mb_env mb_stdin mb_stdout mb_stderr = do
   maybeClose mb_stdin
   maybeClose mb_stdout
   maybeClose mb_stderr
-  return $ procHandle r
+  return ph
  where
   maybeClose :: Maybe Handle -> IO ()
   maybeClose (Just  hdl)
@@ -824,7 +828,7 @@ runInteractiveProcess1
   -> IO (Handle,Handle,Handle,ProcessHandle)
 runInteractiveProcess1 fun cmd = do
   (mb_in, mb_out, mb_err, p) <-
-      unwrapHandles <$> createProcess_ fun
+      createProcess_ fun
            cmd{ std_in  = CreatePipe,
                 std_out = CreatePipe,
                 std_err = CreatePipe }
@@ -861,7 +865,9 @@ when the process died as the result of a signal.
 -}
 system :: String -> IO ExitCode
 system "" = ioException (ioeSetErrorString (mkIOError InvalidArgument "system" Nothing Nothing) "null command")
-system str = procHandle <$> createProcess_ "system" (shell str) { delegate_ctlc = True } >>= waitForProcess
+system str = do
+  (_,_,_,p) <- createProcess_ "system" (shell str) { delegate_ctlc = True }
+  waitForProcess p
 
 
 --TODO: in a later release {-# DEPRECATED rawSystem "Use 'callProcess' (or 'spawnProcess' and 'waitForProcess') instead" #-}
@@ -875,4 +881,6 @@ It will therefore behave more portably between operating systems than 'system'.
 The return codes and possible failures are the same as for 'system'.
 -}
 rawSystem :: String -> [String] -> IO ExitCode
-rawSystem cmd args = procHandle <$> createProcess_ "rawSystem" (proc cmd args) { delegate_ctlc = True } >>= waitForProcess
+rawSystem cmd args = do
+  (_,_,_,p) <- createProcess_ "rawSystem" (proc cmd args) { delegate_ctlc = True }
+  waitForProcess p
diff --git a/System/Process/Internals.hs b/System/Process/Internals.hs
index 99196c9..299f834 100644
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@ -90,8 +90,8 @@ import System.Process.Posix
 createProcess_
   :: String                     -- ^ function name (for error messages)
   -> CreateProcess
-  -> IO ProcRetHandles
-createProcess_ = createProcess_Internal
+  -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
+createProcess_ msg proc_ = unwrapHandles <$> createProcess_Internal msg proc_
 {-# INLINE createProcess_ #-}
 
 -- ------------------------------------------------------------------------
@@ -171,8 +171,8 @@ runGenProcess_
  -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
 -- On Windows, setting delegate_ctlc has no impact
 runGenProcess_ fun c (Just sig) (Just sig') | isDefaultSignal sig && sig == sig'
-                         = unwrapHandles <$> createProcess_ fun c { delegate_ctlc = True }
-runGenProcess_ fun c _ _ = unwrapHandles <$> createProcess_ fun c
+                         = createProcess_ fun c { delegate_ctlc = True }
+runGenProcess_ fun c _ _ = createProcess_ fun c
 
 -- ---------------------------------------------------------------------------
 -- createPipe
diff --git a/process.cabal b/process.cabal
index 6734c25..b339938 100644
--- a/process.cabal
+++ b/process.cabal
@@ -1,5 +1,5 @@
 name:          process
-version:       1.4.3.0
+version:       1.4.3.1
 -- NOTE: Don't forget to update ./changelog.md
 license:       BSD3
 license-file:  LICENSE
diff --git a/tests/T9775/T9775_fail.hs b/tests/T9775/T9775_fail.hs
index a3e239e..b2cc020 100644
--- a/tests/T9775/T9775_fail.hs
+++ b/tests/T9775/T9775_fail.hs
@@ -3,5 +3,5 @@ module Main where
 import System.Process
 
 main
- = do (_,_,_,p) <- createProcess_ "T9775_fail" (proc "main" [])
+ = do (_,_,_,p) <- createProcess (proc "main" [])
       waitForProcess p >>= print
diff --git a/tests/T9775/T9775_good.hs b/tests/T9775/T9775_good.hs
index 6634ad3..a66c316 100644
--- a/tests/T9775/T9775_good.hs
+++ b/tests/T9775/T9775_good.hs
@@ -3,5 +3,5 @@ module Main where
 import System.Process
 
 main
- = do (_,_,_,p) <- createProcess_ "T9775_good" (proc "main" []{ use_process_jobs = True })
+ = do (_,_,_,p) <- createProcess ((proc "main" []){ use_process_jobs = True })
       waitForProcess p >>= print



More information about the ghc-commits mailing list