From fe50f514d5602b06ff585ad3aa168d609f6a1fcc 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/program@1549 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_daemon.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index ead969b..a0e6bdb 100644 --- a/src/rrd_daemon.c +++ b/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.11.0