Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.7.1: add System.PosixCompat.Process containing getProcessID #8

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Version 0.7.1 (2023-12-06) Santa Clause edition

- Add `System.PosixCompat.Process` module, exporting `getProcessID`

## Version 0.7 (2023-03-15)

- Remote `System.PosixCompat.User` module
- Remove `System.PosixCompat.User` module

## Version 0.6 (2022-05-22)

Expand Down
2 changes: 2 additions & 0 deletions src/System/PosixCompat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/System/PosixCompat/Process.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{-# LANGUAGE CPP #-}

{-|
This module intends to make the operations of @System.Posix.Process@ available
on all platforms.
-}
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
12 changes: 12 additions & 0 deletions tests/ProcessSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module ProcessSpec (processSpec) where

import System.PosixCompat
import Test.HUnit
import Test.Hspec

processSpec :: Spec
processSpec = do
describe "getProcessID" $ do
it "should work on Windows and Unix" $ do
pid <- getProcessID
assert $ pid > 0
2 changes: 2 additions & 0 deletions tests/main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module Main where

import MkstempSpec
import LinksSpec
import ProcessSpec

import Test.Hspec

main :: IO ()
main = hspec $ do
mkstempSpec
linksSpec
processSpec
10 changes: 6 additions & 4 deletions unix-compat.cabal
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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
package when available. When it isn't available,
portable implementations are used.

homepage: http://github.com/haskell-pkg-janitors/unix-compat
homepage: https://github.com/haskell-pkg-janitors/unix-compat
license: BSD3
license-file: LICENSE
author: Björn Bringert, Duncan Coutts, Jacob Stanley, Bryan O'Sullivan
maintainer: Mitchell Rosen <mitchellwrosen@gmail.com>
maintainer: https://github.com/haskell-pkg-janitors
category: System
build-type: Simple
cabal-version: >= 1.10
Expand All @@ -20,7 +20,7 @@ extra-source-files:

source-repository head
type: git
location: git@github.com:haskell-pkg-janitors/unix-compat.git
location: https://github.com/haskell-pkg-janitors/unix-compat.git

flag old-time
description: build against old-time package
Expand All @@ -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
Expand Down Expand Up @@ -85,6 +86,7 @@ Test-Suite unix-compat-testsuite
other-modules:
MkstempSpec
LinksSpec
ProcessSpec

-- ghc-options:
-- -Wall
Expand Down