public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Alex Dubov <oakad@yahoo•com>
To: Stephen Hemminger <shemminger@linux-foundation•org>
Cc: netdev@vger•kernel.org
Subject: iproute2: make arpd daemon write pid file on fork
Date: Fri, 12 Aug 2011 16:23:24 +1000	[thread overview]
Message-ID: <201108121623.24984.oakad@yahoo.com> (raw)
In-Reply-To: <20110811110029.023a5955@nehalam.ftrdhcpuser.net>

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);

       reply	other threads:[~2011-08-12  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1313080925.3635.YahooMailNeo@web121018.mail.ne1.yahoo.com>
     [not found] ` <20110811110029.023a5955@nehalam.ftrdhcpuser.net>
2011-08-12  6:23   ` Alex Dubov [this message]
2011-08-12 16:15     ` iproute2: make arpd daemon write pid file on fork Stephen Hemminger
2011-08-15  5:42       ` Alex Dubov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201108121623.24984.oakad@yahoo.com \
    --to=oakad@yahoo$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shemminger@linux-foundation$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox