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.
*/
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;
extern char hostname_g[];
extern cdtime_t interval_g;
+extern int pidfile_from_cli;
extern int timeout_g;
#endif /* COLLECTD_H */
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)