Skip to content

Commit

Permalink
[daemon-manager.cc] Don't daemonize if we're reincarnating (since we …
Browse files Browse the repository at this point in the history
…already daemonized in the previous life).
  • Loading branch information
caldwell committed Nov 14, 2011
1 parent c490ce5 commit f15eb92
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions daemon-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}

if (!foreground)
bool reincarnating = !!getenv("dm_running_daemons_fd");

if (!foreground && !reincarnating)
daemonize();

if (pidfile != "")
Expand All @@ -96,9 +98,8 @@ int main(int argc, char **argv)

vector<class daemon*> daemons = load_daemons(users);

char *fd_str;
if (fd_str = getenv("dm_running_daemons_fd")) {
FILE *import = fdopen(atoi(fd_str), "r+");
if (reincarnating) {
FILE *import = fdopen(atoi(getenv("dm_running_daemons_fd")), "r+");
try {
if (!import) throw_strerr("fdopen() failed");
unsetenv("dm_running_daemons_fd");
Expand Down

0 comments on commit f15eb92

Please sign in to comment.