packages feed

unix-process-conduit 0.2.2 → 0.2.2.1

raw patch · 3 files changed

+40/−11 lines, 3 files

Files

Data/Conduit/Process/Unix.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                      #-} {-# LANGUAGE DeriveDataTypeable       #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE OverloadedStrings        #-}@@ -38,7 +39,7 @@ import           Control.Arrow                   ((***)) import           Control.Concurrent              (forkIO) import           Control.Concurrent              (threadDelay)-import           Control.Concurrent.MVar         (MVar, modifyMVar,+import           Control.Concurrent.MVar         (MVar, modifyMVar, modifyMVar_,                                                   newEmptyMVar, newMVar,                                                   putMVar, readMVar, swapMVar,                                                   takeMVar)@@ -92,9 +93,21 @@ import           System.Posix.Types              (CPid (..), Fd, ProcessID) import           System.Process import           System.Process.Internals        (ProcessHandle (..),-                                                  ProcessHandle__ (..),-                                                  withProcessHandle_)+                                                  ProcessHandle__ (..)) +processHandleMVar :: ProcessHandle -> MVar ProcessHandle__+#if MIN_VERSION_process(1, 2, 0)+processHandleMVar (ProcessHandle m _) = m+#else+processHandleMVar (ProcessHandle m) = m+#endif++withProcessHandle_+        :: ProcessHandle+        -> (ProcessHandle__ -> IO ProcessHandle__)+        -> IO ()+withProcessHandle_ ph io = modifyMVar_ (processHandleMVar ph) io+ -- | Kill a process by sending it the KILL (9) signal. -- -- Since 0.1.0@@ -168,6 +181,9 @@         , std_err = maybe Inherit (const CreatePipe) mstderr         , close_fds = True         , create_group = True+#if MIN_VERSION_process(1, 2, 0)+        , delegate_ctlc = False+#endif         }  ignoreExceptions :: IO () -> IO ()@@ -263,8 +279,8 @@ -- -- Since 0.2.1 trackProcess :: ProcessTracker -> ProcessHandle -> IO TrackedProcess-trackProcess pt ph@(ProcessHandle mph) = mask_ $ do-    mpid <- readMVar mph+trackProcess pt ph = mask_ $ do+    mpid <- readMVar $ processHandleMVar ph     mpid' <- case mpid of         ClosedHandle{} -> return NoPid         OpenHandle pid -> do@@ -325,6 +341,9 @@             , std_err = UseHandle writerH             , close_fds = True             , create_group = True+#if MIN_VERSION_process(1, 2, 0)+            , delegate_ctlc = False+#endif             }         ignoreExceptions $ addAttachMessage pipes ph         void $ forkIO $ ignoreExceptions $
test/Data/Conduit/Process/UnixSpec.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, BangPatterns #-}+{-# LANGUAGE CPP, OverloadedStrings, BangPatterns #-} module Data.Conduit.Process.UnixSpec where  import Test.Hspec (describe, it, shouldBe, Spec)@@ -56,7 +56,12 @@             Nothing         terminateProcess pid         res <- waitForProcess pid-        res `shouldBe` ExitFailure (fromIntegral sigTERM)+        res `shouldBe` ExitFailure+#if MIN_VERSION_process(1, 2, 0)+            (negate $ fromIntegral sigTERM)+#else+            (fromIntegral sigTERM)+#endif     it "killProcess works" $ do         let src = lift (threadDelay 1000000) >> src         pid <- forkExecuteFile@@ -69,7 +74,12 @@             Nothing         killProcess pid         res <- waitForProcess pid-        res `shouldBe` ExitFailure (fromIntegral sigKILL)+        res `shouldBe` ExitFailure+#if MIN_VERSION_process(1, 2, 0)+            (negate $ fromIntegral sigKILL)+#else+            (fromIntegral sigKILL)+#endif     it "environment is set" $ do         (sink, getLBS) <- iorefSink         pid <- forkExecuteFile@@ -81,6 +91,6 @@             (Just sink)             Nothing         res <- waitForProcess pid-        lbs <- getLBS+        lbs <- fmap (filter (L.isPrefixOf "foo=") . L.split 10) getLBS         res `shouldBe` ExitSuccess-        lbs `shouldBe` L.fromChunks ["foo=bar\n"]+        lbs `shouldBe` [L.fromChunks ["foo=bar"]]
unix-process-conduit.cabal view
@@ -2,7 +2,7 @@ --  documentation, see http://haskell.org/cabal/users-guide/  name:                unix-process-conduit-version:             0.2.2+version:             0.2.2.1 synopsis:            Run processes on Unix systems, with a conduit interface description:         This library allows you to provide @conduit@ datatypes for the input and output streams. Note that you must compile your programs with @-threaded@. homepage:            https://github.com/snoyberg/conduit