From gnb@itga.com.au  Tue Jun 26 20:10:17 2001
Return-Path: <gnb@itga.com.au>
Received: from ns.itga.com.au (ns.itga.com.au [202.53.40.210])
	by hub.freebsd.org (Postfix) with ESMTP id A1CC237B405
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Jun 2001 20:10:15 -0700 (PDT)
	(envelope-from gnb@itga.com.au)
Received: from lightning.itga.com.au (lightning.itga.com.au [192.168.71.20])
	by ns.itga.com.au (8.9.3/8.9.3) with ESMTP id NAA04229
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2001 13:10:12 +1000 (EST)
	(envelope-from gnb@itga.com.au)
Received: from hellcat.itga.com.au (hellcat.itga.com.au [192.168.71.163])
	by lightning.itga.com.au (8.9.3/8.9.3) with ESMTP id NAA25639;
	Wed, 27 Jun 2001 13:08:57 +1000 (EST)
Received: (from gnb@localhost)
	by hellcat.itga.com.au (8.11.4/8.11.4) id f5R38vB21346;
	Wed, 27 Jun 2001 13:08:57 +1000 (EST)
	(envelope-from gnb)
Message-Id: <200106270308.f5R38vB21346@hellcat.itga.com.au>
Date: Wed, 27 Jun 2001 13:08:57 +1000 (EST)
From: Gregory Bond <gnb@itga.com.au>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] allow newsyslog to signal process groups
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         28435
>Category:       bin
>Synopsis:       [patch] allow newsyslog to signal process groups
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gad
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 26 20:20:01 PDT 2001
>Closed-Date:    Sun May 04 21:19:45 PDT 2003
>Last-Modified:  Sun May 04 21:19:45 PDT 2003
>Originator:     Gregory Bond
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
ITG Australia Limited
>Environment:
System: FreeBSD hellcat.itga.com.au 4.3-STABLE FreeBSD 4.3-STABLE #21: Mon Jun 18 13:41:36 EST 2001 toor@hellcat.itga.com.au:/usr/obj/usr/src/sys/Hellcat i386

>Description:

Newsyslog allows signalling of a single process when log files are rotated.
But some applications have several processes that need to be signalled.

>How-To-Repeat:

Examine the source/man page.

>Fix:

The attached patch (against 4-Stable) allows the use of a negative PID 
in the pidfile to send the signal to a process group instead of a single
process.  See the kill(2) man page.


Index: newsyslog.8
===================================================================
RCS file: /usr/ncvs/src/usr.sbin/newsyslog/newsyslog.8,v
retrieving revision 1.23.2.4
diff -u -r1.23.2.4 newsyslog.8
--- newsyslog.8	2001/04/26 02:37:08	1.23.2.4
+++ newsyslog.8	2001/06/27 02:57:25
@@ -280,7 +280,12 @@
 field is present, a
 .Ar signal_number
 is sent the process id contained in this
-file.  This field must start with "/" in order to be recognized
+file.  If this number is negative, it is treated as (the negative of) 
+a process group ID and the signal is sent to all members of that 
+process group.  See the 
+.Xr kill 2
+man page for details.
+This field must start with "/" in order to be recognized
 properly.
 .It Ar signal_number
 This optional field specifies
Index: newsyslog.c
===================================================================
RCS file: /usr/ncvs/src/usr.sbin/newsyslog/newsyslog.c,v
retrieving revision 1.25.2.2
diff -u -r1.25.2.2 newsyslog.c
--- newsyslog.c	2000/10/20 00:44:27	1.25.2.2
+++ newsyslog.c	2001/06/27 02:55:37
@@ -738,7 +738,8 @@
 	else {
 		if (fgets(line, BUFSIZ, f)) {
 			pid = atol(line);
-			if (pid < MIN_PID || pid > MAX_PID) {
+			if (pid >= 0 && (pid < MIN_PID || pid > MAX_PID) ||
+			    pid < 0 && (pid > -MIN_PID || pid < -MAX_PID)) {
 				warnx("preposterous process number: %d", (int) pid);
 				pid = 0;
 			}
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gad 
Responsible-Changed-By: gad 
Responsible-Changed-When: Tue Mar 4 16:16:15 PST 2003 
Responsible-Changed-Why:  
I will add a change to newsyslog to add this ability, although I 
will connect it to some config-entry setting, instead of just assuming 
a negative value means a process-group should be notified. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28435 

From: Garance A Drosehn <gad@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, gnb@itga.com.au
Cc:  
Subject: Re: bin/28435: [patch] allow newsyslog to signal process groups
Date: Sat, 8 Mar 2003 15:39:47 -0500

    I have now added the 'U' flag for newsyslog entries which
 need to notify a process-group.  This change is only avaiable
 in -current for now, but I'll MFC it into stable after I write
 the man page update, and after the freeze is off of stable.
 
 -- 
 Garance Alistair Drosehn     =               gad@FreeBSD.org
 
State-Changed-From-To: open->closed 
State-Changed-By: gad 
State-Changed-When: Sun May 4 21:18:30 PDT 2003 
State-Changed-Why:  
The changes for the 'U' flag have now been committed to the 
freebsd-stable branch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28435 
>Unformatted:
