Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jun 2001 13:08:57 +1000 (EST)
From:      Gregory Bond <gnb@itga.com.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/28435: [patch] allow newsyslog to signal process groups
Message-ID:  <200106270308.f5R38vB21346@hellcat.itga.com.au>

next in thread | raw e-mail | index | archive | help

>Number:         28435
>Category:       bin
>Synopsis:       [patch] allow newsyslog to signal process groups
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 26 20:20:01 PDT 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106270308.f5R38vB21346>