From ce53f0f1f936ae0fad65aa5765cbbe021dfa9359 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Wed, 24 Jun 2009 10:27:09 +0200 Subject: proper way how to daemonize --- src/Daemon/CrashWatcher.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'src/Daemon/CrashWatcher.cpp') diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 674a695..f13d842 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -571,38 +571,11 @@ void CCrashWatcher::GStartWatch() g_main_run (m_pMainloop); } - -void CCrashWatcher::Daemonize() -{ - Lock(); - Debug("Daemonize..."); - // forking to background - pid_t pid = fork(); - if (pid < 0) - { - throw CABRTException(EXCEP_FATAL, "CCrashWatcher::Daemonize(): Fork error"); - } - /* parent exits */ - if (pid > 0) _exit(0); - /* child (daemon) continues */ - pid_t sid = setsid(); - if(sid == -1) - { - throw CABRTException(EXCEP_FATAL, "CCrashWatcher::Daemonize(): setsid failed"); - } - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - /* we need a pid file for the child process */ - CreatePidFile(); - GStartWatch(); -} - void CCrashWatcher::Run() { + Debug("Runnig..."); Lock(); CreatePidFile(); - Debug("Runnig..."); GStartWatch(); } -- cgit