Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from eevans/double_fork
Browse files Browse the repository at this point in the history
avoid becoming session leader (double-fork)
  • Loading branch information
jedisct1 committed Aug 24, 2011
2 parents 12c987b + 3f95507 commit 0662402
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/daemonize.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ void dodaemonize(void)
_("Unable to detach from the current session: %s"),
strerror(errno)); /* continue anyway */
}

/* Fork again so we're not a session leader */
if ((child = fork()) == (pid_t) -1) {
logfile(LOG_ERR, _("Unable to background: [fork: %s] #2"),
strerror(errno));
return;
} else if ( child != (pid_t) 0) {
_exit(EXIT_SUCCESS); /* parent exits */
}

chdir("/");
i = open_max();
do {
Expand Down

0 comments on commit 0662402

Please sign in to comment.