[collectd] [PATCH] Added -P command line option.

Sebastian Harl sh at tokkee.org
Wed Oct 11 23:03:42 CEST 2006


This option may be used to set the pid file, overwriting any settings found
in the config file.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/collectd.c   |   10 ++++++++--
 src/collectd.pod |    5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/collectd.c b/src/collectd.c
index 0d9c90f..e069bfe 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 @@ #endif
 
 		c = getopt (argc, argv, "hC:"
 #if COLLECT_DAEMON
-				"f"
+				"fP:"
 #endif
 		);
 
@@ -318,6 +319,10 @@ #endif
 				configfile = optarg;
 				break;
 #if COLLECT_DAEMON
+			case 'P':
+				pidfile      = optarg;
+				have_pidfile = 1;
+				break;
 			case 'f':
 				daemonize = 0;
 				break;
@@ -368,7 +373,8 @@ #if COLLECT_DAEMON
 	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 fcad460..6cd1218 100644
--- a/src/collectd.pod
+++ b/src/collectd.pod
@@ -110,6 +110,11 @@ Specify an alternative config file. This
 change B<collectd>'s behavior. The path may be relative to the current working
 directory.
 
+=item B<-P> I<E<lt>pid-fileE<gt>>
+
+Specify an alternative pid file. This overwrites any settings in the config 
+file.
+
 =item B<-f>
 
 Don't fork to the background. I<collectd> will also B<not> close standard file
-- 
1.4.2.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061011/94bcee6a/attachment.pgp


More information about the collectd mailing list