aboutsummaryrefslogtreecommitdiff
path: root/Utility/Daemon.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-02 12:27:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-02 12:27:32 -0400
commit250a25c8572e557772a9973542f9cfca6ac10b9b (patch)
tree7d4aaa36a7d5b6c3c5e03fb844fb844da4c037d2 /Utility/Daemon.hs
parenta39c161ab377eed381186bc57953cd59d6188108 (diff)
get rid of __WINDOWS__, use mingw32_HOST_OS
The latter is harder for me to remember, but avoids build failures in code used by the configure program.
Diffstat (limited to 'Utility/Daemon.hs')
-rw-r--r--Utility/Daemon.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs
index ad0950de2..124005795 100644
--- a/Utility/Daemon.hs
+++ b/Utility/Daemon.hs
@@ -12,7 +12,7 @@ module Utility.Daemon where
import Common
import Utility.LogFile
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
import System.Posix
#else
import System.PosixCompat
@@ -26,7 +26,7 @@ import System.Posix.Types
-
- When successful, does not return. -}
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
daemonize logfd pidfile changedirectory a = do
maybe noop checkalreadyrunning pidfile
_ <- forkProcess child1
@@ -58,7 +58,7 @@ daemonize = error "daemonize is not implemented on Windows" -- TODO
lockPidFile :: FilePath -> IO ()
lockPidFile file = do
createDirectoryIfMissing True (parentDir file)
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
fd <- openFd file ReadWrite (Just stdFileMode) defaultFileFlags
locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0)
fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags
@@ -85,7 +85,7 @@ alreadyRunning = error "Daemon is already running."
-
- If it's running, returns its pid. -}
checkDaemon :: FilePath -> IO (Maybe ProcessID)
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
checkDaemon pidfile = do
v <- catchMaybeIO $
openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags
@@ -110,7 +110,7 @@ checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
{- Stops the daemon, safely. -}
stopDaemon :: FilePath -> IO ()
-#ifndef __WINDOWS__
+#ifndef mingw32_HOST_OS
stopDaemon pidfile = go =<< checkDaemon pidfile
where
go Nothing = noop