From: Sebastian Harl Date: Wed, 11 Oct 2006 21:03:42 +0000 (+0200) Subject: Add the `-P' command line option. X-Git-Tag: collectd-3.11.0~68^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e109cd486b6075425e58ceeb25fcf9de14797d2b;p=collectd.git Add the `-P' command line option. This option may be used to set the pid file, overwriting any settings found in the config file. Signed-off-by: Sebastian Harl --- diff --git a/src/collectd.c b/src/collectd.c index 0d9c90fc..e069bfeb 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -282,6 +282,7 @@ int main (int argc, char **argv) #if COLLECT_DAEMON struct sigaction sigChldAction; char *pidfile = PIDFILE; + int have_pidfile = 0; pid_t pid; int daemonize = 1; #endif @@ -305,7 +306,7 @@ int main (int argc, char **argv) c = getopt (argc, argv, "hC:" #if COLLECT_DAEMON - "f" + "fP:" #endif ); @@ -318,6 +319,10 @@ int main (int argc, char **argv) configfile = optarg; break; #if COLLECT_DAEMON + case 'P': + pidfile = optarg; + have_pidfile = 1; + break; case 'f': daemonize = 0; break; @@ -368,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 ((1 != have_pidfile) + && ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)) { fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever."); return (1); diff --git a/src/collectd.pod b/src/collectd.pod index 26185eea..095463c1 100644 --- a/src/collectd.pod +++ b/src/collectd.pod @@ -110,6 +110,11 @@ Specify an alternative config file. This is the place to go when you wish to change B's behavior. The path may be relative to the current working directory. +=item B<-P> Ipid-fileE> + +Specify an alternative pid file. This overwrites any settings in the config +file. + =item B<-f> Don't fork to the background. I will also B close standard file