summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2015-03-03 20:07:59 +0000
committerrpaulo <rpaulo@FreeBSD.org>2015-03-03 20:07:59 +0000
commit39e3a5804ea618bf5b2888b828d2ad2a037a9ae2 (patch)
tree7b8ba3e21b382fdcf5e73f68f8c31fb09e7fe712 /usr.sbin/syslogd
parent3f63c17a2ccd3c66109afd95c46d00dbd554b8a3 (diff)
downloadFreeBSD-src-39e3a5804ea618bf5b2888b828d2ad2a037a9ae2.zip
FreeBSD-src-39e3a5804ea618bf5b2888b828d2ad2a037a9ae2.tar.gz
Add and document an option to cause syslogd to run in the
foreground. This allows a separate process to monitor when and how syslogd exits. That process can then restart syslogd if needed. Differential Revision: https://reviews.freebsd.org/D1985 Submitted by: Ravi Pokala Reviewed by: allanjude (man page)
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.813
-rw-r--r--usr.sbin/syslogd/syslogd.c10
2 files changed, 19 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index 5b175a6..063c83b 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -36,7 +36,7 @@
.Nd log systems messages
.Sh SYNOPSIS
.Nm
-.Op Fl 468ACcdkNnosTuv
+.Op Fl 468ACcdFkNnosTuv
.Op Fl a Ar allowed_peer
.Op Fl b Ar bind_address
.Op Fl f Ar config_file
@@ -213,6 +213,17 @@ This is probably only of use to developers working on
Specify the pathname of an alternate configuration file;
the default is
.Pa /etc/syslog.conf .
+.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 k
Disable the translation of
messages received with facility
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index bc054b8..a79086e 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -271,6 +271,7 @@ static struct filed *Files; /* Log files that we write to */
static struct filed consfile; /* Console */
static int Debug; /* debug flag */
+static int Foreground = 0; /* Run in foreground, instead of daemonizing */
static int resolve = 1; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static const char *LocalDomain; /* our local domain name */
@@ -360,7 +361,7 @@ main(int argc, char *argv[])
dprintf("madvise() failed: %s\n", strerror(errno));
bindhostname = NULL;
- while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nNop:P:sS:Tuv"))
+ while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv"))
!= -1)
switch (ch) {
case '4':
@@ -396,6 +397,9 @@ main(int argc, char *argv[])
case 'f': /* configuration file */
ConfFile = optarg;
break;
+ case 'F': /* run in foreground instead of daemon */
+ Foreground++;
+ break;
case 'k': /* keep remote kern fac */
KeepKernFac = 1;
break;
@@ -487,14 +491,14 @@ main(int argc, char *argv[])
warn("cannot open pid file");
}
- if (!Debug) {
+ if ((!Foreground) && (!Debug)) {
ppid = waitdaemon(0, 0, 30);
if (ppid < 0) {
warn("could not become daemon");
pidfile_remove(pfh);
exit(1);
}
- } else {
+ } else if (Debug) {
setlinebuf(stdout);
}
OpenPOWER on IntegriCloud