summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Utility/Daemon.hs8
-rw-r--r--Utility/LogFile.hs12
2 files changed, 4 insertions, 16 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs
index afba68535..1654821af 100644
--- a/Utility/Daemon.hs
+++ b/Utility/Daemon.hs
@@ -21,6 +21,7 @@ import Control.Concurrent.Async
import System.PosixCompat.Types
#endif
+#ifndef mingw32_HOST_OS
{- Run an action as a daemon, with all output sent to a file descriptor.
-
- Can write its pid to a file, to guard against multiple instances
@@ -28,7 +29,6 @@ import System.PosixCompat.Types
-
- When successful, does not return. -}
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
-#ifndef mingw32_HOST_OS
daemonize logfd pidfile changedirectory a = do
maybe noop checkalreadyrunning pidfile
_ <- forkProcess child1
@@ -52,8 +52,6 @@ daemonize logfd pidfile changedirectory a = do
wait =<< asyncWithUnmask (\unmask -> unmask a)
out
out = exitImmediately ExitSuccess
-#else
-daemonize = error "daemonize is not implemented on Windows" -- TODO
#endif
{- Locks the pid file, with an exclusive, non-blocking lock.
@@ -112,13 +110,11 @@ checkDaemon pidfile = do
checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
#endif
+#ifndef mingw32_HOST_OS
{- Stops the daemon, safely. -}
stopDaemon :: FilePath -> IO ()
-#ifndef mingw32_HOST_OS
stopDaemon pidfile = go =<< checkDaemon pidfile
where
go Nothing = noop
go (Just pid) = signalProcess sigTERM pid
-#else
-stopDaemon = error "stopDaemon is not implemented on Windows" -- TODO
#endif
diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs
index 1c29b9ff4..4e76116ba 100644
--- a/Utility/LogFile.hs
+++ b/Utility/LogFile.hs
@@ -13,14 +13,12 @@ import Common
import System.Posix.Types
-openLog :: FilePath -> IO Fd
#ifndef mingw32_HOST_OS
+openLog :: FilePath -> IO Fd
openLog logfile = do
rotateLog logfile
openFd logfile WriteOnly (Just stdFileMode)
defaultFileFlags { append = True }
-#else
-openLog = error "openLog TODO"
#endif
rotateLog :: FilePath -> IO ()
@@ -49,20 +47,14 @@ listLogs logfile = filterM doesFileExist $ reverse $
maxLogs :: Int
maxLogs = 9
-redirLog :: Fd -> IO ()
#ifndef mingw32_HOST_OS
+redirLog :: Fd -> IO ()
redirLog logfd = do
mapM_ (redir logfd) [stdOutput, stdError]
closeFd logfd
-#else
-redirLog _ = error "redirLog TODO"
-#endif
redir :: Fd -> Fd -> IO ()
-#ifndef mingw32_HOST_OS
redir newh h = do
closeFd h
void $ dupTo newh h
-#else
-redir _ _ = error "redir TODO"
#endif