Code

Merge pull request #553 from Whissi/issue_553
authorPierre-Yves Ritschard <pyr@spootnik.org>
Mon, 28 Jul 2014 21:00:28 +0000 (23:00 +0200)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Mon, 28 Jul 2014 21:00:28 +0000 (23:00 +0200)
collectd ignores command line argument "-P"

src/collectd.c
src/collectd.h
src/configfile.c

index d25975308e9689b15fa9126503f35ed056353a67..6c37c61408dbcaa2078ff2884a3ae57704d16cbd 100644 (file)
@@ -41,6 +41,7 @@
  */
 char hostname_g[DATA_MAX_NAME_LEN];
 cdtime_t interval_g;
+int  pidfile_from_cli = 0;
 int  timeout_g;
 #if HAVE_LIBKSTAT
 kstat_ctl_t *kc;
@@ -439,6 +440,7 @@ int main (int argc, char **argv)
 #if COLLECT_DAEMON
                        case 'P':
                                global_option_set ("PIDFile", optarg);
+                               pidfile_from_cli = 1;
                                break;
                        case 'f':
                                daemonize = 0;
index 969aedaa483c0f1bddcfe7baa2052096c05cc783..558dc7a3b6383c8e04b6844b423103938ccf34d3 100644 (file)
@@ -296,6 +296,7 @@ typedef uint64_t cdtime_t;
 
 extern char     hostname_g[];
 extern cdtime_t interval_g;
+extern int      pidfile_from_cli;
 extern int      timeout_g;
 
 #endif /* COLLECTD_H */
index 0e54f267f9fdd08c15d4d4d11a427f409d708723..c5d3e3668495a8b43de6c16c82649e986878c52b 100644 (file)
@@ -891,6 +891,13 @@ int global_option_set (const char *option, const char *value)
        if (i >= cf_global_options_num)
                return (-1);
 
+       if (strcasecmp (option, "PIDFile") == 0 && pidfile_from_cli == 1)
+       {
+               DEBUG ("Configfile: Ignoring `PIDFILE' option because "
+                       "command-line option `-P' take precedence.");
+               return (0);
+       }
+
        sfree (cf_global_options[i].value);
 
        if (value != NULL)