diff options
author | Ravi Pokala <rpokala@FreeBSD.org> | 2019-11-22 16:53:30 +0000 |
---|---|---|
committer | Ravi Pokala <rpokala@FreeBSD.org> | 2019-11-22 16:53:30 +0000 |
commit | 90e43b446d7f3cfd571feee5554627a100b7c8bf (patch) | |
tree | 764c4519717c598a5df6f45f5e1fc0259f13b665 /usr.sbin/rpc.statd | |
parent | 9c770a27cee56467a431b14b14f053ef25ba1997 (diff) | |
download | src-test2-90e43b446d7f3cfd571feee5554627a100b7c8bf.tar.gz src-test2-90e43b446d7f3cfd571feee5554627a100b7c8bf.zip |
Add and document options to allow rpc.lockd and rpc.statd to run in the
foreground.
This allows a separate process to monitor when and how those programs exit.
That process can then restart them if needed.
Submitted by: Alex Burlyga
Reviewed by: bcr, imp
MFC after: 1 week
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D22474
Notes
Notes:
svn path=/head/; revision=355006
Diffstat (limited to 'usr.sbin/rpc.statd')
-rw-r--r-- | usr.sbin/rpc.statd/rpc.statd.8 | 14 | ||||
-rw-r--r-- | usr.sbin/rpc.statd/statd.c | 14 |
2 files changed, 24 insertions, 4 deletions
diff --git a/usr.sbin/rpc.statd/rpc.statd.8 b/usr.sbin/rpc.statd/rpc.statd.8 index 32559ade7160..a4a143f19e2a 100644 --- a/usr.sbin/rpc.statd/rpc.statd.8 +++ b/usr.sbin/rpc.statd/rpc.statd.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2007 +.Dd November 21, 2019 .Dt RPC.STATD 8 .Os .Sh NAME @@ -38,6 +38,7 @@ .Sh SYNOPSIS .Nm .Op Fl d +.Op Fl F .Op Fl h Ar bindip .Op Fl p Ar port .Sh DESCRIPTION @@ -71,6 +72,17 @@ These messages are logged with level LOG_DEBUG and facility LOG_DAEMON. Error conditions are logged irrespective of this option, using level LOG_ERR. +.It Fl F +Run +.Nm +in the foreground, rather than going into daemon mode. +This is useful if some other process uses +.Xr fork 2 +and +.Xr exec 3 +to run +.Nm , +and wants to monitor when and how it exits. .It Fl h Ar bindip Specify specific IP addresses to bind to. This option may be specified multiple times. diff --git a/usr.sbin/rpc.statd/statd.c b/usr.sbin/rpc.statd/statd.c index 50368824756f..ecd31b8ddf68 100644 --- a/usr.sbin/rpc.statd/statd.c +++ b/usr.sbin/rpc.statd/statd.c @@ -89,15 +89,19 @@ main(int argc, char **argv) char *endptr; char **hosts_bak; int have_v6 = 1; + int foreground = 0; int maxrec = RPC_MAXDATASIZE; int attempt_cnt, port_len, port_pos, ret; char **port_list; - while ((ch = getopt(argc, argv, "dh:p:")) != -1) + while ((ch = getopt(argc, argv, "dFh:p:")) != -1) switch (ch) { case 'd': debug = 1; break; + case 'F': + foreground = 1; + break; case 'h': ++nhosts; hosts_bak = hosts; @@ -288,7 +292,11 @@ main(int argc, char **argv) /* Note that it is NOT sensible to run this program from inetd - the */ /* protocol assumes that it will run immediately at boot time. */ - daemon(0, 0); + if ((foreground == 0) && daemon(0, 0) < 0) { + err(1, "cannot fork"); + /* NOTREACHED */ + } + openlog("rpc.statd", 0, LOG_DAEMON); if (debug) syslog(LOG_INFO, "Starting - debug enabled"); else syslog(LOG_INFO, "Starting"); @@ -618,7 +626,7 @@ clearout_service(void) static void usage(void) { - fprintf(stderr, "usage: rpc.statd [-d] [-h <bindip>] [-p <port>]\n"); + fprintf(stderr, "usage: rpc.statd [-d] [-F] [-h <bindip>] [-p <port>]\n"); exit(1); } |