From 24f9a7e9ce5dc86bc1c38e826998e3cdffe1e24d Mon Sep 17 00:00:00 2001 From: ners Date: Wed, 1 Nov 2023 20:33:11 +0100 Subject: [PATCH] add System.PosixCompat.Process --- CHANGELOG.md | 6 +++++- src/System/PosixCompat.hs | 2 ++ src/System/PosixCompat/Process.hs | 25 +++++++++++++++++++++++++ unix-compat.cabal | 3 ++- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/System/PosixCompat/Process.hs diff --git a/CHANGELOG.md b/CHANGELOG.md index 340c32b..10f8e04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ +## Version 0.7.1 (2023-11-01) + +- Add `System.PosixCompat.Process` module + ## Version 0.7 (2023-03-15) -- Remote `System.PosixCompat.User` module +- Remove `System.PosixCompat.User` module ## Version 0.6 (2022-05-22) diff --git a/src/System/PosixCompat.hs b/src/System/PosixCompat.hs index 22b06dd..2fa2546 100644 --- a/src/System/PosixCompat.hs +++ b/src/System/PosixCompat.hs @@ -7,6 +7,7 @@ package, on other platforms it emulates the operations as far as possible. -} module System.PosixCompat ( module System.PosixCompat.Files + , module System.PosixCompat.Process , module System.PosixCompat.Temp , module System.PosixCompat.Time , module System.PosixCompat.Types @@ -15,6 +16,7 @@ module System.PosixCompat ( ) where import System.PosixCompat.Files +import System.PosixCompat.Process import System.PosixCompat.Temp import System.PosixCompat.Time import System.PosixCompat.Types diff --git a/src/System/PosixCompat/Process.hs b/src/System/PosixCompat/Process.hs new file mode 100644 index 0000000..b1656eb --- /dev/null +++ b/src/System/PosixCompat/Process.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE CPP #-} + +{-| +This module makes the operations exported by @System.Posix.Process@ +available on all platforms. On POSIX systems it re-exports operations from +@System.Posix.Process@, on other platforms it emulates the operations as far +as possible. +-} +module System.PosixCompat.Process ( + getProcessID + ) where + +#ifdef mingw32_HOST_OS + +import System.Posix.Types (ProcessID) +import System.Win32.Process (getCurrentProcessID) + +getProcessID :: IO ProcessID +getProcessID = fromIntegral <$> getCurrentProcessID + +#else + +import System.Posix.Process + +#endif diff --git a/unix-compat.cabal b/unix-compat.cabal index 58b18c4..a471e56 100644 --- a/unix-compat.cabal +++ b/unix-compat.cabal @@ -1,5 +1,5 @@ name: unix-compat -version: 0.7 +version: 0.7.1 synopsis: Portable POSIX-compatibility layer. description: This package provides portable implementations of parts of the unix package. This package re-exports the unix @@ -36,6 +36,7 @@ Library System.PosixCompat System.PosixCompat.Extensions System.PosixCompat.Files + System.PosixCompat.Process System.PosixCompat.Temp System.PosixCompat.Time System.PosixCompat.Types