aboutsummaryrefslogtreecommitdiff
path: root/Utility/PID.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-11 15:22:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-11 15:25:59 -0400
commit0653cfa5a8454d90cfda396ac64fe2f237f6b5c9 (patch)
treef7caa9897ad0bdfc57805d464a7c5526f6821d5d /Utility/PID.hs
parentbc8878f61615891353c984d18f36ff3fd23a1a90 (diff)
fix windows build (and make --stop work on windows, incidentially)
The Utility.PID will clean up other code soon.
Diffstat (limited to 'Utility/PID.hs')
-rw-r--r--Utility/PID.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Utility/PID.hs b/Utility/PID.hs
new file mode 100644
index 000000000..4867bd6de
--- /dev/null
+++ b/Utility/PID.hs
@@ -0,0 +1,31 @@
+{- process ids
+ -
+ - Copyright 2014 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE CPP #-}
+
+module Utility.PID where
+
+#ifndef mingw32_HOST_OS
+import System.Posix.Types (ProcessID)
+import System.Posix.Process (getProcessID)
+#else
+import System.Win32.Process (ProcessId)
+import System.Win32.Process.Current (getCurrentProcessId)
+#endif
+
+#ifndef mingw32_HOST_OS
+type PID = ProcessID
+#else
+type PID = ProcessId
+#endif
+
+getPID :: IO PID
+#ifndef mingw32_HOST_OS
+getPID = getProcessID
+#else
+getPID = getCurrentProcessId
+#endif