summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 204cf4f)
raw | patch | inline | side by side (parent: 204cf4f)
author | Thomas D <whissi@whissi.de> | |
Wed, 12 Feb 2014 14:32:15 +0000 (15:32 +0100) | ||
committer | Thomas D <whissi@whissi.de> | |
Wed, 12 Feb 2014 15:31:46 +0000 (16:31 +0100) |
The "PIDFile" value from command-line option "-P", which should take
precedence over any "PIDFile" value from configuration files, could be
overwritten if a configuration file contained the "PIDFile" option.
We introduced a new global variable "pidfile_from_cli" which will be set
to 1 when the command-line option "-P" was detected and the
"global_option_set" function will only set the "PIDFile" option if
"pidfile_from_cli" is 0.
precedence over any "PIDFile" value from configuration files, could be
overwritten if a configuration file contained the "PIDFile" option.
We introduced a new global variable "pidfile_from_cli" which will be set
to 1 when the command-line option "-P" was detected and the
"global_option_set" function will only set the "PIDFile" option if
"pidfile_from_cli" is 0.
src/collectd.c | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/configfile.c | patch | blob | history |
diff --git a/src/collectd.c b/src/collectd.c
index d25975308e9689b15fa9126503f35ed056353a67..6c37c61408dbcaa2078ff2884a3ae57704d16cbd 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
*/
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;
#if COLLECT_DAEMON
case 'P':
global_option_set ("PIDFile", optarg);
+ pidfile_from_cli = 1;
break;
case 'f':
daemonize = 0;
diff --git a/src/collectd.h b/src/collectd.h
index 969aedaa483c0f1bddcfe7baa2052096c05cc783..558dc7a3b6383c8e04b6844b423103938ccf34d3 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
extern char hostname_g[];
extern cdtime_t interval_g;
+extern int pidfile_from_cli;
extern int timeout_g;
#endif /* COLLECTD_H */
diff --git a/src/configfile.c b/src/configfile.c
index 0e54f267f9fdd08c15d4d4d11a427f409d708723..c5d3e3668495a8b43de6c16c82649e986878c52b 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
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)