From owner-svn-src-all@FreeBSD.ORG Tue Dec 22 22:11:18 2009 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3FEC1065695; Tue, 22 Dec 2009 22:11:18 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id C06D08FC19; Tue, 22 Dec 2009 22:11:16 +0000 (UTC) Received: from mail.geekcn.org (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id D721CA5A1A2; Wed, 23 Dec 2009 06:11:11 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by mail.geekcn.org (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with LMTP id 3QZXoI3PdWwU; Wed, 23 Dec 2009 06:10:52 +0800 (CST) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id F3C14A5A123; Wed, 23 Dec 2009 06:10:45 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to:content-type; b=Nq70/p4u9OaFsBm2KFdbh1Le8aCF5i1AgLWRbqycBnSZYFy0ThNRowKqcQGAEPl8Q hlZKWDMBXO+EV18HYhHdg== Message-ID: <4B3143CE.1000608@delphij.net> Date: Tue, 22 Dec 2009 14:10:22 -0800 From: Xin LI Organization: The Geek China Organization User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.5) Gecko/20091220 Thunderbird/3.0 ThunderBrowse/3.2.6.8 MIME-Version: 1.0 To: Stanislav Sedov References: <200912212012.nBLKC2aS039479@svn.freebsd.org> <20091222133217.aad538b0.stas@FreeBSD.org> In-Reply-To: <20091222133217.aad538b0.stas@FreeBSD.org> Content-Type: multipart/mixed; boundary="------------050907050800030009080600" Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Xin LI Subject: Re: svn commit: r200806 - head/usr.sbin/newsyslog X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Dec 2009 22:11:18 -0000 This is a multi-part message in MIME format. --------------050907050800030009080600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 2009/12/22 13:32, Stanislav Sedov wrote: > On Mon, 21 Dec 2009 20:12:02 +0000 (UTC) > Xin LI mentioned: > >> Author: delphij >> Date: Mon Dec 21 20:12:01 2009 >> New Revision: 200806 >> URL: http://svn.freebsd.org/changeset/base/200806 >> >> Log: >> Don't consider non-existence of a PID file an error, we should be able >> to proceed anyway as this most likely mean that the process has been >> terminated. > > Or the process has not created the PID file and can be screwed up by rotating > its log file. What about making this optional controlled by a command line > switch? It might be a more safe alternative. Yes probably. I think the both case (can't find the PID file, or the PID file is empty) should be counted, as they may represent the similar situation, however, I think we'd better leave the current behavior default, since it's the most case. Do you think the attached patch makes sense? Cheers, -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die --------------050907050800030009080600 Content-Type: text/plain; name="newsyslog-option.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="newsyslog-option.diff" Index: newsyslog.8 =================================================================== --- newsyslog.8 (revision 200868) +++ newsyslog.8 (working copy) @@ -17,7 +17,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd February 24, 2005 +.Dd December 23, 2009 .Dt NEWSYSLOG 8 .Os .Sh NAME @@ -25,7 +25,7 @@ .Nd maintain system log files to manageable sizes .Sh SYNOPSIS .Nm -.Op Fl CFNnrsv +.Op Fl CFNPnrsv .Op Fl R Ar tagname .Op Fl a Ar directory .Op Fl d Ar directory @@ -169,6 +169,10 @@ or .Fl CC options when creating log files is the only objective. +.It Fl P +Prevent further action if we should send signal but the +.Dq pidfile +is empty or does not exist. .It Fl R Ar tagname Specify that .Nm Index: newsyslog.c =================================================================== --- newsyslog.c (revision 200868) +++ newsyslog.c (working copy) @@ -167,6 +167,7 @@ int noaction = 0; /* Don't do anything, just show it */ int norotate = 0; /* Don't rotate */ int nosignal; /* Do not send any signals */ +int enforcepid = 0; /* If PID file does not exist or empty, do nothing */ int force = 0; /* Force the trim no matter what */ int rotatereq = 0; /* -R = Always rotate the file(s) as given */ /* on the command (this also requires */ @@ -580,7 +581,7 @@ *p = '\0'; /* Parse command line options. */ - while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FNR:")) != -1) + while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FNR:P")) != -1) switch (ch) { case 'a': archtodir++; @@ -624,6 +625,8 @@ case 'N': norotate++; break; + case 'P': + enforcepid++; case 'R': rotatereq++; requestor = strdup(optarg); @@ -1779,7 +1782,7 @@ f = fopen(ent->pid_file, "r"); if (f == NULL) { - if (errno == ENOENT) { + if (errno == ENOENT && enforcepid == 0) { /* * Warn if the PID file doesn't exist, but do * not consider it an error. Most likely it @@ -1801,7 +1804,7 @@ * has terminated, so it should be safe to rotate any * log files that the process would have been using. */ - if (feof(f)) { + if (feof(f) && enforcepid == 0) { swork->sw_pidok = 1; warnx("pid file is empty: %s", ent->pid_file); } else --------------050907050800030009080600--