From lawrance@FreeBSD.org  Mon Jan 30 04:41:11 2006
Return-Path: <lawrance@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3B9F716A420
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 30 Jan 2006 04:41:11 +0000 (GMT)
	(envelope-from lawrance@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 089A143D48
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 30 Jan 2006 04:41:11 +0000 (GMT)
	(envelope-from lawrance@FreeBSD.org)
Received: from freefall.freebsd.org (lawrance@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0U4fArr078743
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 30 Jan 2006 04:41:10 GMT
	(envelope-from lawrance@freefall.freebsd.org)
Received: (from lawrance@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0U4fAPr078742;
	Mon, 30 Jan 2006 04:41:10 GMT
	(envelope-from lawrance)
Message-Id: <200601300441.k0U4fAPr078742@freefall.freebsd.org>
Date: Mon, 30 Jan 2006 04:41:10 GMT
From: Sam Lawrance <lawrance@FreeBSD.org>
Reply-To: Sam Lawrance <lawrance@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] allow rc scripts to kill process after a timeout
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         92523
>Category:       conf
>Synopsis:       [patch] allow rc scripts to kill process after a timeout
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-rc
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 30 04:50:02 GMT 2006
>Closed-Date:    
>Last-Modified:  Fri Nov 30 09:50:00 UTC 2012
>Originator:     Sam Lawrance
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD freefall.freebsd.org 6.0-STABLE FreeBSD 6.0-STABLE #0: Sat Dec 10 03:18:20 UTC 2005 kensmith@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386


>Description:
	Services stopped with a new style rc script wait indefinitely for the
process to die (using the default behaviour).  For some services which become
wedged sometimes and don't respond to a TERM signal, it would be useful to
be able to kill the process after a timeout.

>How-To-Repeat:
>Fix:

	http://people.freebsd.org/~lawrance/patch-rc.subr

This patch adds the wait_max_for_pids function.  It is similar to wait_for_pids
but the first argument is a timeout which specifies the maximum amount of time
to wait.

The default stop sequence is then changed to check the ${name}_stop_timeout
variable.  If it is set, the script will call wait_max_for_pids and the process
will be killed after the timeout.

If ${name}_stop_timeout is unset it the script will use wait_for_pids (ie behaviour
unchanged).

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->rc 
Responsible-Changed-By: lawrance 
Responsible-Changed-When: Mon Jan 30 05:12:34 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92523 
State-Changed-From-To: open->feedback 
State-Changed-By: crees 
State-Changed-When: Thu Nov 1 17:57:25 UTC 2012 
State-Changed-Why:  
Oops, this is so old you must have removed the patchfile!  Perhaps it 
would be just as easy to test for the _stop_timeout variable inside 
wait_for_pids? 

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

From: mitsuru y <mitsururike@gmail.com>
To: bug-followup@FreeBSD.org, lawrance@FreeBSD.org
Cc:  
Subject: Re: conf/92523: [patch] allow rc scripts to kill process after a timeout
Date: Fri, 30 Nov 2012 13:52:55 +0900

 It is archived at
 http://web.archive.org/web/20060921232848/http://people.freebsd.org/~lawrance/patch-rc.subr
 
 --
 mitsuru

From: mitsuru y <mitsururike@gmail.com>
To: bug-followup@FreeBSD.org, lawrance@FreeBSD.org
Cc:  
Subject: Re: conf/92523: [patch] allow rc scripts to kill process after a timeout
Date: Fri, 30 Nov 2012 18:48:08 +0900

 --f46d04479f3d0d266304cfb34c15
 Content-Type: text/plain; charset=UTF-8
 
 I have modified the patch.
  - to be applied cleanly for 8.2-RELEASE ( and 9-STABLE).
  - introduce default_stop_timeout
  - kill -KILL only if timeout
 
 --
 mitsuru
 
 --f46d04479f3d0d266304cfb34c15
 Content-Type: application/octet-stream; name="patch-rc.subr"
 Content-Disposition: attachment; filename="patch-rc.subr"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_ha54nbi90
 
 LS0tIHJjLnN1YnIub3JpZwkyMDEyLTExLTMwIDE3OjI5OjQ5LjAwMDAwMDAwMCArMDkwMAorKysg
 cmMuc3VicgkyMDEyLTExLTMwIDE4OjMyOjM2LjAwMDAwMDAwMCArMDkwMApAQCAtMzk4LDYgKzM5
 OCw0MiBAQAogfQogCiAjCisjIHdhaXRfbWF4X2Zvcl9waWRzIHRpbWVvdXQgcGlkIFtwaWQgLi4u
 XQorIwlzcGlucyB1bnRpbCBub25lIG9mIHRoZSBwaWRzIGV4aXN0LCBvciB1bnRpbCBhIG1heGlt
 dW0gb2YKKyMJInRpbWVvdXQiIHNlY29uZHMgaGF2ZSBlbGFwc2VkICh3aGljaGV2ZXIgY29tZXMg
 Zmlyc3QpLgorIword2FpdF9tYXhfZm9yX3BpZHMoKQoreworCV90aW1lb3V0PSQxCisJc2hpZnQK
 KwlfbGlzdD0iJEAiCisJaWYgWyAteiAiJF9saXN0IiBdOyB0aGVuCisJCXJldHVybiAwCisJZmkK
 KwlfcHJlZml4PQorCXdoaWxlIFsgJF90aW1lb3V0IC1ndCAwIF0gOyBkbworCQlfbmxpc3Q9IiI7
 CisJCWZvciBfaiBpbiAkX2xpc3Q7IGRvCisJCQlpZiBraWxsIC0wICRfaiAyPi9kZXYvbnVsbDsg
 dGhlbgorCQkJCV9ubGlzdD0iJHtfbmxpc3R9JHtfbmxpc3Q6KyB9JF9qIgorCQkJZmkKKwkJZG9u
 ZQorCQlpZiBbI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