diff options
| author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-24 10:27:09 +0200 |
|---|---|---|
| committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-24 10:27:09 +0200 |
| commit | ce53f0f1f936ae0fad65aa5765cbbe021dfa9359 (patch) | |
| tree | 9822aff1dd82e660a27e6f92b087db8044a37c4a /src/Daemon/CrashWatcher.cpp | |
| parent | 44b4926781e2e8751488f3ae18614aa1e63e1138 (diff) | |
| download | abrt-ce53f0f1f936ae0fad65aa5765cbbe021dfa9359.tar.gz abrt-ce53f0f1f936ae0fad65aa5765cbbe021dfa9359.tar.xz abrt-ce53f0f1f936ae0fad65aa5765cbbe021dfa9359.zip | |
proper way how to daemonize
Diffstat (limited to 'src/Daemon/CrashWatcher.cpp')
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 29 |
1 files changed, 1 insertions, 28 deletions
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(); } |
