[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <201108121623.24984.oakad@yahoo.com>
Date: Fri, 12 Aug 2011 16:23:24 +1000
From: Alex Dubov <oakad@...oo.com>
To: Stephen Hemminger <shemminger@...ux-foundation.org>
Cc: netdev@...r.kernel.org
Subject: iproute2: make arpd daemon write pid file on fork
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);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists