From owner-svn-src-stable@freebsd.org Sat Jan 9 05:02:37 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3137FA6976C; Sat, 9 Jan 2016 05:02:37 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BA631DE0; Sat, 9 Jan 2016 05:02:36 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0952aNA030059; Sat, 9 Jan 2016 05:02:36 GMT (envelope-from rpokala@FreeBSD.org) Received: (from rpokala@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0952a4c030057; Sat, 9 Jan 2016 05:02:36 GMT (envelope-from rpokala@FreeBSD.org) Message-Id: <201601090502.u0952a4c030057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rpokala set sender to rpokala@FreeBSD.org using -f From: Ravi Pokala Date: Sat, 9 Jan 2016 05:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293462 - stable/10/usr.sbin/syslogd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 05:02:37 -0000 Author: rpokala Date: Sat Jan 9 05:02:35 2016 New Revision: 293462 URL: https://svnweb.freebsd.org/changeset/base/293462 Log: MFC r279567, r279568: 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. Approved by: jhb Sponsored by: Panasas, Inc. Modified: stable/10/usr.sbin/syslogd/syslogd.8 stable/10/usr.sbin/syslogd/syslogd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/syslogd/syslogd.8 ============================================================================== --- stable/10/usr.sbin/syslogd/syslogd.8 Sat Jan 9 03:30:33 2016 (r293461) +++ stable/10/usr.sbin/syslogd/syslogd.8 Sat Jan 9 05:02:35 2016 (r293462) @@ -28,7 +28,7 @@ .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd May 13, 2008 +.Dd March 3, 2015 .Dt SYSLOGD 8 .Os .Sh NAME @@ -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 develope 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 Modified: stable/10/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/10/usr.sbin/syslogd/syslogd.c Sat Jan 9 03:30:33 2016 (r293461) +++ stable/10/usr.sbin/syslogd/syslogd.c Sat Jan 9 05:02:35 2016 (r293462) @@ -271,6 +271,7 @@ static struct filed *Files; /* Log files 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 */ @@ -372,7 +373,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': @@ -408,6 +409,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; @@ -499,14 +503,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); } @@ -726,7 +730,7 @@ usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: syslogd [-468ACcdknosTuv] [-a allowed_peer]", + "usage: syslogd [-468ACcdFknosTuv] [-a allowed_peer]", " [-b bind_address] [-f config_file]", " [-l [mode:]path] [-m mark_interval]", " [-P pid_file] [-p log_socket]");