From d0e1c846b9049ae5bd227587db7990641a76e83f Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 30 Sep 2008 18:42:34 +0000 Subject: [PATCH] The daemon should behave the same way w/r/t files whether we "-g" or not. -- kevin git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1549 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_daemon.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index ead969b4..a0e6bdbf 100644 --- a/program/src/rrd_daemon.c +++ b/program/src/rrd_daemon.c @@ -1999,6 +1999,7 @@ static int daemonize (void) /* {{{ */ { int status; int fd; + char *base_dir; fd = open_pidfile(); if (fd < 0) return fd; @@ -2006,7 +2007,6 @@ static int daemonize (void) /* {{{ */ if (!stay_foreground) { pid_t child; - char *base_dir; child = fork (); if (child < 0) @@ -2019,17 +2019,6 @@ static int daemonize (void) /* {{{ */ return (1); } - /* Change into the /tmp directory. */ - base_dir = (config_base_dir != NULL) - ? config_base_dir - : "/tmp"; - status = chdir (base_dir); - if (status != 0) - { - fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir); - return (-1); - } - /* Become session leader */ setsid (); @@ -2043,6 +2032,17 @@ static int daemonize (void) /* {{{ */ dup (0); } /* if (!stay_foreground) */ + /* Change into the /tmp directory. */ + base_dir = (config_base_dir != NULL) + ? config_base_dir + : "/tmp"; + status = chdir (base_dir); + if (status != 0) + { + fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir); + return (-1); + } + install_signal_handlers(); openlog ("rrdcached", LOG_PID, LOG_DAEMON); -- 2.30.2