X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcollectd.c;h=64da57650a2627774e3cf3e78913b0f20810c6ee;hb=8389947b881b59af994a9b6c8af706446edb25f2;hp=2720590e22ab8b4d3bb18d4ac3f149982511aa54;hpb=a92f2c43e37614bb400e7a2fcd2f9f161b695901;p=collectd.git diff --git a/src/collectd.c b/src/collectd.c index 2720590e..64da5765 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -123,6 +123,8 @@ static void exit_usage (char *name) " General:\n" " -C Configuration file.\n" " Default: "CONFIGFILE"\n" + " -P PID-file.\n" + " Default: "PIDFILE"\n" #if COLLECT_DAEMON " -f Don't fork to the background.\n" #endif @@ -191,7 +193,7 @@ static int start_client (void) curtime = time (NULL); /* Issue all plugins */ - plugin_read_all (); + plugin_read_all (&loop); if (gettimeofday (&tv_now, NULL) < 0) { @@ -205,7 +207,7 @@ static int start_client (void) continue; } - while (nanosleep (&ts_wait, &ts_wait) == -1) + while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1)) { if (errno != EINTR) { @@ -281,7 +283,7 @@ int main (int argc, char **argv) char *configfile = CONFIGFILE; #if COLLECT_DAEMON struct sigaction sigChldAction; - char *pidfile = PIDFILE; + char *pidfile = NULL; pid_t pid; int daemonize = 1; #endif @@ -291,6 +293,8 @@ int main (int argc, char **argv) #if HAVE_LIBRRD operating_mode = MODE_LOCAL; +#else + operating_mode = MODE_CLIENT; #endif /* open syslog */ @@ -303,7 +307,7 @@ int main (int argc, char **argv) c = getopt (argc, argv, "hC:" #if COLLECT_DAEMON - "f" + "fP:" #endif ); @@ -316,6 +320,9 @@ int main (int argc, char **argv) configfile = optarg; break; #if COLLECT_DAEMON + case 'P': + pidfile = optarg; + break; case 'f': daemonize = 0; break; @@ -366,7 +373,8 @@ int main (int argc, char **argv) sigChldAction.sa_handler = SIG_IGN; sigaction (SIGCHLD, &sigChldAction, NULL); - if ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL) + if ((pidfile == NULL) + && ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)) { fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever."); return (1);