aboutsummaryrefslogtreecommitdiff
path: root/Utility/Daemon.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-10 16:05:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-10 16:05:44 -0400
commit92e057e4619d1ff4fe361d2d215a63ee0630a9a0 (patch)
tree2cee12a69b5aedb136c0b6646a2f2d6a05839b9e /Utility/Daemon.hs
parentbf726fb2c0ec8cf0e306843d34df6d052b9a1936 (diff)
unmask async exceptions after fork
Turns out that forkProcess masks async exceptions. Unmask them so that the daemon code can use them for thread IPC. There is some risk this introduces breakage in git-annex, but it would be breakage that would already occur when the assistant was run with --foreground.
Diffstat (limited to 'Utility/Daemon.hs')
-rw-r--r--Utility/Daemon.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs
index 2f942769a..12beb235a 100644
--- a/Utility/Daemon.hs
+++ b/Utility/Daemon.hs
@@ -16,6 +16,7 @@ import Utility.LogFile
#ifndef mingw32_HOST_OS
import System.Posix
+import Control.Concurrent.Async
#else
import System.PosixCompat
#endif
@@ -46,7 +47,9 @@ daemonize logfd pidfile changedirectory a = do
nullfd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
redir nullfd stdInput
redirLog logfd
- a
+ {- forkProcess masks async exceptions; unmask them inside
+ - the action. -}
+ wait =<< asyncWithUnmask (\unmask -> unmask a)
out
out = exitImmediately ExitSuccess
#else