iproute2: make arpd daemon write pid file on fork

3 messages, 2 authors, 2011-08-15 · open the first message on its own page

iproute2: make arpd daemon write pid file on fork

From: Alex Dubov <oakad@yahoo.com>
Date: 2011-08-12 06:23:34

Current version of arpd included with iproute2-2.6.37 will fork 
unconditionally on start-up (using daemon() library call). This causes 
problems with distro start-up scripts, as PID of the started daemon can not be 
reliably obtained, hampering orderly daemon shutdown process.

The included patch makes arpd write it's own pid file after fork, in a common 
LSB fashion, so as to better inter-operate with start up scripts. Removal of 
stale pid files is handled elsewhere.
--- misc/arpd.c.orig	2011-01-08 04:54:30.000000000 +1100
+++ misc/arpd.c	2011-08-12 16:04:51.098754397 +1000
@@ -41,6 +41,7 @@
 
 DB	*dbase;
 char	*dbname = "/var/lib/arpd/arpd.db";
+char	*pidfname = "/var/run/arpd.pid";
 
 int	ifnum;
 int	*ifvec;
@@ -780,6 +781,17 @@
 		goto do_abort;
 	}
 
+	do {
+		FILE *fp = fopen(pidfname, "w");
+		if (fp) {
+			fprintf(fp, "%ld\n", (long)getpid());
+			fclose(fp);
+		} else {
+			perror("arpd: pid fopen");
+			goto do_abort;
+		}
+	} while (0);
+
 	openlog("arpd", LOG_PID | LOG_CONS, LOG_DAEMON);
 	catch_signal(SIGINT, sig_exit);
 	catch_signal(SIGTERM, sig_exit);

Re: iproute2: make arpd daemon write pid file on fork

From: Stephen Hemminger <hidden>
Date: 2011-08-12 16:16:07

On Fri, 12 Aug 2011 16:23:24 +1000
Alex Dubov [off-list ref] wrote:
Current version of arpd included with iproute2-2.6.37 will fork 
unconditionally on start-up (using daemon() library call). This causes 
problems with distro start-up scripts, as PID of the started daemon can not be 
reliably obtained, hampering orderly daemon shutdown process.

The included patch makes arpd write it's own pid file after fork, in a common 
LSB fashion, so as to better inter-operate with start up scripts. Removal of 
stale pid files is handled elsewhere.
I already checked in a version which has the -p pidfile option.

Re: iproute2: make arpd daemon write pid file on fork

From: Alex Dubov <oakad@yahoo.com>
Date: 2011-08-15 05:42:10

----- Original Message -----
quoted
 The included patch makes arpd write it's own pid file after fork, in a 
common 
quoted
 LSB fashion, so as to better inter-operate with start up scripts. Removal 
of 
quoted
 stale pid files is handled elsewhere.
I already checked in a version which has the -p pidfile option.
Thanks for that.
It will be enough for arpd to fit with the rest of init scripts.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help