Support -p <pidfile> option

It's needed to avoid using /var/run/rtadvd.pid on ATF tests and
run multiple instances of rump.rtadvd on a test.
This commit is contained in:
ozaki-r 2016-12-16 09:09:38 +00:00
parent 7ae52b382e
commit 0739b470cb
3 changed files with 20 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2224 $>
# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2225 $>
#
#
# [Note: This file does not mention every change made to the NetBSD source tree.
@ -433,3 +433,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
ptrace(2): Add hardware assisted breakpoint/watchpoint API:
PT_READ_WATCHPOINT, PT_WRITE_WATCHPOINT and
PT_COUNT_WATCHPOINTS [kamil 20161215]
rtadvd(8): Support -p <pidfile> option. [ozaki-r 20161216]

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rtadvd.8,v 1.24 2012/12/13 21:49:38 wiz Exp $
.\" $NetBSD: rtadvd.8,v 1.25 2016/12/16 09:09:38 ozaki-r Exp $
.\" $KAME: rtadvd.8,v 1.24 2002/05/31 16:16:08 jinmei Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd December 13, 2006
.Dd December 16, 2016
.Dt RTADVD 8
.Os
.Sh NAME
@ -39,6 +39,7 @@
.Op Fl DdfRs
.Op Fl c Ar configfile
.Op Fl M Ar ifname
.Op Fl p Ar pidfile
.Ar interface ...
.Sh DESCRIPTION
.Nm
@ -140,6 +141,13 @@ option, which enables routing renumbering protocol support.
.\"Enables mobile IPv6 support.
.\"This changes the content of router advertisement option, as well as
.\"permitted configuration directives.
.It Fl p Ar pidfile
Specify an alternate location,
.Ar pidfile ,
for the PID file.
By default,
.Pa /var/run/rtadvd.pid
is used.
.It Fl R
Accept router renumbering requests.
If you enable it, an

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtadvd.c,v 1.51 2015/11/11 07:48:41 ozaki-r Exp $ */
/* $NetBSD: rtadvd.c,v 1.52 2016/12/16 09:09:38 ozaki-r Exp $ */
/* $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $ */
/*
@ -180,9 +180,10 @@ main(int argc, char *argv[])
int i, ch;
int fflag = 0, logopt;
struct passwd *pw;
const char *pidfilepath = NULL;
/* get command line options and arguments */
#define OPTIONS "c:dDfM:Rs"
#define OPTIONS "c:dDfM:p:Rs"
while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
#undef OPTIONS
switch (ch) {
@ -201,6 +202,9 @@ main(int argc, char *argv[])
case 'M':
mcastif = optarg;
break;
case 'p':
pidfilepath = optarg;
break;
case 'R':
fprintf(stderr, "rtadvd: "
"the -R option is currently ignored.\n");
@ -217,7 +221,7 @@ main(int argc, char *argv[])
if (argc == 0) {
fprintf(stderr,
"usage: rtadvd [-DdfRs] [-c conffile]"
" [-M ifname] interface ...\n");
" [-M ifname] [-p pidfile] interface ...\n");
exit(1);
}
@ -262,7 +266,7 @@ main(int argc, char *argv[])
#ifdef __NetBSD__
/* record the current PID */
if (pidfile(NULL) < 0) {
if (pidfile(pidfilepath) < 0) {
syslog(LOG_ERR,
"<%s> failed to open the pid log file, run anyway.",
__func__);