From: bluhm Date: Mon, 15 Jun 2015 21:42:15 +0000 (+0000) Subject: Implement a -F switch, that tells syslogd to stay in foreground. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5feb6878f491c13d19a819258ec7d0b14457b0d1;p=openbsd Implement a -F switch, that tells syslogd to stay in foreground. OK benno@; input millert@; no objections deraadt@ --- diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index 3c0e906ceef..bc0f6729d66 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: syslogd.8,v 1.33 2015/01/30 14:09:49 bluhm Exp $ +.\" $OpenBSD: syslogd.8,v 1.34 2015/06/15 21:42:15 bluhm Exp $ .\" .\" Copyright (c) 1983, 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -30,7 +30,7 @@ .\" from: @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $NetBSD: syslogd.8,v 1.3 1996/01/02 17:41:48 perry Exp $ .\" -.Dd $Mdocdate: January 30 2015 $ +.Dd $Mdocdate: June 15 2015 $ .Dt SYSLOGD 8 .Os .Sh NAME @@ -39,7 +39,7 @@ .Sh SYNOPSIS .Nm syslogd .Bk -words -.Op Fl 46dhnuV +.Op Fl 46dFhnuV .Op Fl a Ar path .Op Fl C Ar CAfile .Op Fl f Ar config_file @@ -85,6 +85,9 @@ and do not disassociate from the controlling terminal. Specify the pathname of an alternate configuration file; the default is .Pa /etc/syslog.conf . +.It Fl F +Run in the foreground instead of disassociating from the controlling +terminal and running as a background daemon. .It Fl h Include the hostname when forwarding messages to a remote host. .It Fl m Ar mark_interval diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 7ef38cf477a..cbf224d0afb 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.163 2015/06/12 19:20:43 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.164 2015/06/15 21:42:15 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -205,6 +205,7 @@ struct filed consfile; int nunix = 1; /* Number of Unix domain sockets requested */ char *path_unix[MAXUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */ int Debug; /* debug flag */ +int Foreground; /* run in foreground, instead of daemonizing */ int Startup = 1; /* startup flag */ char LocalHostName[HOST_NAME_MAX+1]; /* our hostname */ char *LocalDomain; /* our local domain name */ @@ -328,7 +329,7 @@ main(int argc, char *argv[]) int ch, i; int lockpipe[2] = { -1, -1}, pair[2], nullfd, fd; - while ((ch = getopt(argc, argv, "46C:dhnuf:m:p:a:s:V")) != -1) + while ((ch = getopt(argc, argv, "46C:dhnuf:Fm:p:a:s:V")) != -1) switch (ch) { case '4': /* disable IPv6 */ IPv4Only = 1; @@ -347,6 +348,9 @@ main(int argc, char *argv[]) case 'f': /* configuration file */ ConfFile = optarg; break; + case 'F': /* foreground */ + Foreground = 1; + break; case 'h': /* RFC 3164 hostnames */ IncludeHostname = 1; break; @@ -557,7 +561,7 @@ main(int argc, char *argv[]) tzset(); - if (!Debug) { + if (!Debug && !Foreground) { char c; pipe(lockpipe); @@ -969,7 +973,7 @@ usage(void) { (void)fprintf(stderr, - "usage: syslogd [-46dhnuV] [-a path] [-C CAfile] [-f config_file]\n" + "usage: syslogd [-46dFhnuV] [-a path] [-C CAfile] [-f config_file]\n" " [-m mark_interval] [-p log_socket] [-s reporting_socket]\n"); exit(1); }