summaryrefslogtreecommitdiff
path: root/src/System/Process/Concurrent.hs
diff options
context:
space:
mode:
authorJoey Hess2020-06-10 15:08:44 -0400
committerJoey Hess2020-06-10 15:08:44 -0400
commita077594770132b4a07b168936d07385ff0c618d6 (patch)
treeb18ee77e8594cfe1be10c4b57ee5b7e0618d91ab /src/System/Process/Concurrent.hs
parent8cda76848192a019529ceee9fcdb45088f9608e8 (diff)
Revert "Added dependency on concurrent-output; removed embedded copy."
This reverts commit dbd3ba3400a3097498252097540ffe8075b00833. Still has the same problem as in 2018!
Diffstat (limited to 'src/System/Process/Concurrent.hs')
-rw-r--r--src/System/Process/Concurrent.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/System/Process/Concurrent.hs b/src/System/Process/Concurrent.hs
new file mode 100644
index 00000000..0e00e4fd
--- /dev/null
+++ b/src/System/Process/Concurrent.hs
@@ -0,0 +1,34 @@
+-- |
+-- Copyright: 2015 Joey Hess <id@joeyh.name>
+-- License: BSD-2-clause
+--
+-- The functions exported by this module are intended to be drop-in
+-- replacements for those from System.Process, when converting a whole
+-- program to use System.Console.Concurrent.
+
+module System.Process.Concurrent where
+
+import System.Console.Concurrent
+import System.Console.Concurrent.Internal (ConcurrentProcessHandle(..))
+import System.Process hiding (createProcess, waitForProcess)
+import System.IO
+import System.Exit
+
+-- | Calls `createProcessConcurrent`
+--
+-- You should use the waitForProcess in this module on the resulting
+-- ProcessHandle. Using System.Process.waitForProcess instead can have
+-- mildly unexpected results.
+createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
+createProcess p = do
+ (i, o, e, ConcurrentProcessHandle h) <- createProcessConcurrent p
+ return (i, o, e, h)
+
+-- | Calls `waitForProcessConcurrent`
+--
+-- You should only use this on a ProcessHandle obtained by calling
+-- createProcess from this module. Using this with a ProcessHandle
+-- obtained from System.Process.createProcess etc will have extremely
+-- unexpected results; it can wait a very long time before returning.
+waitForProcess :: ProcessHandle -> IO ExitCode
+waitForProcess = waitForProcessConcurrent . ConcurrentProcessHandle