packages feed

process 1.6.11.0 → 1.6.12.0

raw patch · 4 files changed

+55/−15 lines, 4 filesdep ~Win32dep ~base

Dependency ranges changed: Win32, base

Files

System/Process.hs view
@@ -49,6 +49,7 @@     showCommandForUser,     Pid,     getPid,+    getCurrentPid,      -- ** Control-C handling on Unix     -- $ctlc-handling@@ -93,8 +94,9 @@ import System.IO.Error (mkIOError, ioeSetErrorString)  #if defined(WINDOWS)-import System.Win32.Process (getProcessId, ProcessId)+import System.Win32.Process (getProcessId, getCurrentProcessId, ProcessId) #else+import System.Posix.Process (getProcessID) import System.Posix.Types (CPid (..)) #endif @@ -256,10 +258,10 @@                      (\(m_in, m_out, m_err, ph) -> action m_in m_out m_err ph)  -- | Cleans up the process.--- --- This function is meant to be invoked from any application level cleanup +--+-- This function is meant to be invoked from any application level cleanup -- handler. It terminates the process, and closes any 'CreatePipe' 'handle's.--- +-- -- @since 1.6.4.0 cleanupProcess :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)                -> IO ()@@ -650,6 +652,24 @@     OpenHandle pid -> return $ Just pid #endif     _ -> return Nothing+++-- ----------------------------------------------------------------------------+-- getCurrentPid++-- | Returns the PID (process ID) of the current process. On POSIX systems,+-- this calls 'getProcessID' from "System.Posix.Process" in the @unix@ package.+-- On Windows, this calls 'getCurrentProcessId' from "System.Win32.Process" in+-- the @Win32@ package.+--+-- @since 1.6.12.0+getCurrentPid :: IO Pid+getCurrentPid =+#ifdef WINDOWS+    getCurrentProcessId+#else+    getProcessID+#endif   -- ----------------------------------------------------------------------------
changelog.md view
@@ -1,5 +1,9 @@ # Changelog for [`process` package](http://hackage.haskell.org/package/process) +## 1.6.12.0 *June 2021*++* Add function `getCurrentPid` to get the currently executing process' ID [#205](https://github.com/haskell/process/pull/205)+ ## 1.6.11.0 *January 2021*  * Windows: Add support for new I/O manager in GHC 8.12[#177](https://github.com/haskell/process/pull/177)
process.cabal view
@@ -1,5 +1,5 @@ name:          process-version:       1.6.11.0+version:       1.6.12.0 -- NOTE: Don't forget to update ./changelog.md license:       BSD3 license-file:  LICENSE@@ -57,7 +57,7 @@         c-sources:             cbits/win32/runProcess.c         other-modules: System.Process.Windows-        build-depends: Win32 >=2.2 && < 2.10+        build-depends: Win32 >=2.2 && < 2.13         -- ole32 and rpcrt4 are needed to create GUIDs for unique named pipes         -- for process.         extra-libraries: kernel32, ole32, rpcrt4@@ -77,7 +77,7 @@      ghc-options: -Wall -    build-depends: base      >= 4.8.2 && < 4.16,+    build-depends: base      >= 4.10 && < 4.17,                    directory >= 1.1 && < 1.4,                    filepath  >= 1.2 && < 1.5,                    deepseq   >= 1.1 && < 1.5
test/main.hs view
@@ -14,6 +14,13 @@ import qualified Data.ByteString.Char8 as S8 import System.Directory (getTemporaryDirectory, removeFile) +isWindows :: Bool+#if WINDOWS+isWindows = True+#else+isWindows = False+#endif+ main :: IO () main = do     res <- handle (return . Left . isDoesNotExistError) $ do@@ -34,7 +41,11 @@                 then putStrLn $ "Success running: " ++ name                 else error $ "echo returned: " ++ show ec -    test "detach_console" $ \cp -> cp { detach_console = True }+    test "vanilla" id++    -- FIXME need to debug this in the future on Windows+    unless isWindows $ test "detach_console" $ \cp -> cp { detach_console = True }+     test "create_new_console" $ \cp -> cp { create_new_console = True }     test "new_session" $ \cp -> cp { new_session = True } @@ -94,15 +105,17 @@       eec <- takeMVar mec       case eec of         Nothing -> return ()-        Just ec -> error $ "waitForProcess not interrupted: sleep exited with " ++ show ec+        Just ec ->+          if isWindows+            then putStrLn "FIXME ignoring known failure on Windows"+            else error $ "waitForProcess not interrupted: sleep exited with " ++ show ec      putStrLn "testing getPid"     do-#ifdef WINDOWS-      (_, Just out, _, p) <- createProcess $ (proc "sh" ["-c", "z=$$; cat /proc/$z/winpid"]) {std_out = CreatePipe}-#else-      (_, Just out, _, p) <- createProcess $ (proc "sh" ["-c", "echo $$"]) {std_out = CreatePipe}-#endif+      (_, Just out, _, p) <-+        if isWindows+          then createProcess $ (proc "sh" ["-c", "z=$$; cat /proc/$z/winpid"]) {std_out = CreatePipe}+          else createProcess $ (proc "sh" ["-c", "echo $$"]) {std_out = CreatePipe}       pid <- getPid p       line <- hGetContents out       putStrLn $ " queried PID: " ++ show pid@@ -110,7 +123,10 @@       _ <- waitForProcess p       hClose out       let numStdoutPid = read (takeWhile isDigit line) :: Pid-      unless (Just numStdoutPid == pid) $ error "subprocess reported unexpected PID"+      unless (Just numStdoutPid == pid) $+        if isWindows+          then putStrLn "FIXME ignoring known failure on Windows"+          else error "subprocess reported unexpected PID"      putStrLn "Tests passed successfully"