aboutsummaryrefslogtreecommitdiff
path: root/Utility/Daemon.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-14 15:44:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-14 15:52:00 -0400
commit28c3b4fdda5809b18f7a046a1923ab2fb5c1b157 (patch)
tree13d674c1c4d60c4604699af6738ffaf9e0598e18 /Utility/Daemon.hs
parentc43e4de3495d8574e731d756c9c6e468d028b01e (diff)
Windows: Fix locking issue that prevented the webapp starting (since 5.20140707).
Reversion introduced in 89c188fac37c20c40b0a9dabeb35403cfa4e4f52. The locking code was wrong; the webapp re-ran itself, saw pid was locked, and so didn't start!
Diffstat (limited to 'Utility/Daemon.hs')
-rw-r--r--Utility/Daemon.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs
index 23d18d2b6..228263911 100644
--- a/Utility/Daemon.hs
+++ b/Utility/Daemon.hs
@@ -21,6 +21,8 @@ import Utility.WinLock
#ifndef mingw32_HOST_OS
import System.Posix
import Control.Concurrent.Async
+#else
+import System.Exit
#endif
#ifndef mingw32_HOST_OS
@@ -54,15 +56,26 @@ daemonize logfd pidfile changedirectory a = do
wait =<< asyncWithUnmask (\unmask -> unmask a)
out
out = exitImmediately ExitSuccess
+#endif
{- To run an action that is normally daemonized in the forground. -}
+#ifndef mingw32_HOST_OS
foreground :: Fd -> Maybe FilePath -> IO () -> IO ()
foreground logfd pidfile a = do
+#else
+foreground :: Maybe FilePath -> IO () -> IO ()
+foreground pidfile a = do
+#endif
maybe noop lockPidFile pidfile
+#ifndef mingw32_HOST_OS
_ <- tryIO createSession
redirLog logfd
+#endif
a
+#ifndef mingw32_HOST_OS
exitImmediately ExitSuccess
+#else
+ exitWith ExitSuccess
#endif
{- Locks the pid file, with an exclusive, non-blocking lock,