X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fcollectd.c;h=88c38acea0990e1aa8684959c55ca9e8d94877e1;hb=8c864f5e634118fce2446ebbba96a1cb7ec39dda;hp=eb5404f8fda21a148d3a6091fbd67814d63fd733;hpb=ff270e6d53374bddca9f3fe0bb7a8c2294548edc;p=collectd.git diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index eb5404f8..88c38ace 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -197,8 +197,10 @@ static int change_basedir (const char *orig_dir) while ((dirlen > 0) && (dir[dirlen - 1] == '/')) dir[--dirlen] = '\0'; - if (dirlen <= 0) + if (dirlen <= 0) { + free (dir); return (-1); + } status = chdir (dir); if (status == 0) @@ -270,7 +272,7 @@ static void update_kstat (void) */ static void exit_usage (int status) { - printf ("Usage: "PACKAGE" [OPTIONS]\n\n" + printf ("Usage: "PACKAGE_NAME" [OPTIONS]\n\n" "Available options:\n" " General:\n" @@ -289,7 +291,7 @@ static void exit_usage (int status) " PID file "PIDFILE"\n" " Plugin directory "PLUGINDIR"\n" " Data directory "PKGLOCALSTATEDIR"\n" - "\n"PACKAGE" "VERSION", http://collectd.org/\n" + "\n"PACKAGE_NAME" "PACKAGE_VERSION", http://collectd.org/\n" "by Florian octo Forster \n" "for contributions see `AUTHORS'\n"); exit (status); @@ -308,7 +310,11 @@ static int do_init (void) #endif #if HAVE_LIBSTATGRAB - if (sg_init ()) + if (sg_init ( +# if HAVE_LIBSTATGRAB_0_90 + 0 +# endif + )) { ERROR ("sg_init: %s", sg_str_error (sg_get_error ())); return (-1); @@ -404,12 +410,14 @@ static int pidfile_create (void) static int pidfile_remove (void) { const char *file = global_option_get ("PIDFile"); + if (file == NULL) + return 0; - DEBUG ("unlink (%s)", (file != NULL) ? file : ""); return (unlink (file)); } /* static int pidfile_remove (const char *file) */ #endif /* COLLECT_DAEMON */ +#ifdef KERNEL_LINUX int notify_upstart (void) { const char *upstart_job = getenv("UPSTART_JOB"); @@ -475,6 +483,7 @@ int notify_systemd (void) close(fd); return 1; } +#endif /* KERNEL_LINUX */ int main (int argc, char **argv) { @@ -594,9 +603,13 @@ int main (int argc, char **argv) /* * Only daemonize if we're not being supervised - * by upstart or systemd. + * by upstart or systemd (when using Linux). */ - if (daemonize && notify_upstart() == 0 && notify_systemd() == 0) + if (daemonize +#ifdef KERNEL_LINUX + && notify_upstart() == 0 && notify_systemd() == 0 +#endif + ) { if ((pid = fork ()) == -1) {