Commit c8214013 authored by Steven Murray's avatar Steven Murray
Browse files

Removed the sanity check of the castor::server::Daemon::daemonize() method

that is carried out when the method checks that the child has successfully
detached from the parent by making sure the return value of getppid() is 1.

I have removed the sanity check because it is time dependent.  If the child
calls getppid() before the parent has enough time to exit then the child
gets the process ID of its true parent as opposed to the process ID of the
init process.
parent 86300cb1
......@@ -31,6 +31,7 @@
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
// constructor
......@@ -222,18 +223,6 @@ void castor::server::Daemon::daemonize() throw (castor::exception::Exception) {
"Failed to daemonize: Failed to run daemon is a new session");
// Sanity check - At this point we are executing as the child process, and
// the parent process should be init with a process ID of 1
const pid_t ppid = getppid();
if (1 != ppid) {
castor::exception::Internal ex;
ex.getMessage() << "Failed to daemonize: "
" Failed to detach from parent process: getppid() returned " << ppid;
throw ex;
// Redirect standard files to /dev/null
freopen("/dev/null", "r", stdin),
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment