Other people have the same problem. See this meaning .
daemonize, Redis , ( getppid). , . , getppid, fork - ( setsid), Linux .
. faq.
daemonize Redis :
void daemonize(void) {
int fd;
if (fork() != 0) exit(0);
setsid();
if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO) close(fd);
}
}
Upstart :
expect daemon
Specifies that the job main process is a daemon, and will fork twice after being run.
init(8) will follow this daemonisation, and will wait for this to occur before running
the job post-start script or considering the job to be running.
Without this stanza init(8) is unable to supervise daemon processes and will
believe them to have stopped as soon as they daemonise on startup.
expect fork
Specifies that the job main process will fork once after being run. init(8) will
follow this fork, and will wait for this to occur before running the job post-start
script or considering the job to be running.
Without this stanza init(8) is unable to supervise forking processes and will believe
them to have stopped as soon as they fork on startup.
Redis, fork fork, .