Install the SIGHUP handler regardless of the daemonization status. This
fixes issue #755.

Signed-off-by: Apollon Oikonomopoulos <[email protected]>
---
Disclaimer: This is merely a suggestion. I'm not even sure this is the right
place to install the signal handler, with all the lazy eval going on, but it
works for me (TM).

 src/Ganeti/Daemon.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Ganeti/Daemon.hs b/src/Ganeti/Daemon.hs
index 6d1082b..a427c9c 100644
--- a/src/Ganeti/Daemon.hs
+++ b/src/Ganeti/Daemon.hs
@@ -356,7 +356,6 @@ daemonize logfile action = do
     setupDaemonEnv "/" (unionFileModes groupModes otherModes)
     setupDaemonFDs (Just logfile) `Control.Exception.catch`
       handlePrepErr False wpipe'
-    _ <- installHandler lostConnection (Catch (handleSigHup logfile)) Nothing
     -- second fork, launches the actual child code; standard
     -- double-fork technique
     _ <- forkProcess (action wpipe')
@@ -407,6 +406,7 @@ genericMain daemon options check_fn prep_fn exec_fn = do
   let processFn = if optDaemonize opts
                     then daemonize log_file
                     else \action -> action Nothing
+  _ <- installHandler lostConnection (Catch (handleSigHup log_file)) Nothing
   processFn $ innerMain daemon opts syslog check_result' prep_fn exec_fn
 
 -- | Full prepare function.
-- 
2.1.0

Reply via email to