From owner-freebsd-ports@FreeBSD.ORG Mon Jun 2 14:36:13 2014 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2614EE90 for ; Mon, 2 Jun 2014 14:36:13 +0000 (UTC) Received: from mail-in-05.arcor-online.net (mail-in-05.arcor-online.net [151.189.21.45]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mx.arcor.de", Issuer "Thawte SSL CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C70182CED for ; Mon, 2 Jun 2014 14:36:12 +0000 (UTC) Received: from mail-in-15-z2.arcor-online.net (mail-in-15-z2.arcor-online.net [151.189.8.32]) by mx.arcor.de (Postfix) with ESMTP id 470E3E3C9F for ; Mon, 2 Jun 2014 16:36:09 +0200 (CEST) Received: from mail-in-09.arcor-online.net (mail-in-09.arcor-online.net [151.189.21.49]) by mail-in-15-z2.arcor-online.net (Postfix) with ESMTP id 07AF333E8E8 for ; Mon, 2 Jun 2014 16:36:09 +0200 (CEST) X-Greylist: Passed host: 188.105.85.75 X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-09.arcor-online.net CD378197793 Received: from lorvorc.mips.inka.de (dslb-188-105-085-075.pools.arcor-ip.net [188.105.85.75]) by mail-in-09.arcor-online.net (Postfix) with ESMTPS id CD378197793 for ; Mon, 2 Jun 2014 16:36:08 +0200 (CEST) Received: from lorvorc.mips.inka.de (localhost [127.0.0.1]) by lorvorc.mips.inka.de (8.14.9/8.14.7) with ESMTP id s52Ea8Av088359 for ; Mon, 2 Jun 2014 16:36:08 +0200 (CEST) (envelope-from news@lorvorc.mips.inka.de) Received: (from news@localhost) by lorvorc.mips.inka.de (8.14.9/8.14.9/Submit) id s52Ea8lx088358 for freebsd-ports@freebsd.org; Mon, 2 Jun 2014 16:36:08 +0200 (CEST) (envelope-from news) To: freebsd-ports@freebsd.org From: Christian Weisgerber Newsgroups: list.freebsd.ports Subject: Re: [net/openntpd] pidfile support Date: Mon, 2 Jun 2014 14:36:08 +0000 (UTC) Lines: 105 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: lorvorc.mips.inka.de 1401719768 88353 ::1 (2 Jun 2014 14:36:08 GMT) X-Complaints-To: usenet@mips.inka.de User-Agent: slrn/1.0.1 (FreeBSD) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jun 2014 14:36:13 -0000 On 2014-06-02, Tomek WaƂaszek wrote: >> Yes, the fix will work but it will be not a generic solution. >> Maybe for those types of programs we should have a generic solution? For >> example add a variable leader="YES", and if this variable will be set then >> the rc script will kill only the 'master' process? >> I wrote a simple patch for the rc.subr, I dont know whether this solution >> is good but anyway it works for me :P >> Patch is in the attachment :) (Here's Tomek's patch that didn't make it to the mailing list.) ---------- diff --git a/rc.subr b/rc.subr index 850bc03..668ea14 100644 --- a/rc.subr +++ b/rc.subr @@ -252,7 +252,7 @@ check_pidfile() debug "pid file ($_pidfile): no pid in file." return fi - _find_processes $_procname $_interpreter '-p '"$_pid" ${_leader:-"NO"} + _find_processes $_procname ${_interpreter:-.} '-p '"$_pid" } # @@ -265,12 +265,10 @@ check_process() { _procname=$1 _interpreter=$2 - _leader=$3 - if [ -z "$_procname" ]; then - err 3 'USAGE: check_process procname [interpreter leader]' + err 3 'USAGE: check_process procname [interpreter]' fi - _find_processes $_procname $_interpreter '-ax' $_leader + _find_processes $_procname ${_interpreter:-.} '-ax' } # @@ -295,13 +293,12 @@ check_process() # _find_processes() { - if [ $# -ne 4 ]; then + if [ $# -ne 3 ]; then err 3 'USAGE: _find_processes procname interpreter psargs' fi _procname=$1 _interpreter=$2 _psargs=$3 - _leader=$4 _pref= if [ $_interpreter != "." ]; then # an interpreted script @@ -341,22 +338,14 @@ _find_processes() _fp_match='case "$_arg0" in $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})"|"[${_procnamebn}]")' fi - + _proccheck="\ - $PS 2>/dev/null -o pid= -o pgid= -o jid= -o command= $_psargs"' | - while read _npid _pgid _jid '"$_fp_args"'; do + $PS 2>/dev/null -o pid= -o jid= -o command= $_psargs"' | + while read _npid _jid '"$_fp_args"'; do '"$_fp_match"' - if checkyesno _leader; - then - if [ "$JID" -eq "$_jid" -a "$_npid" -eq "$_pgid" ]; then - echo -n "$_pref$_npid"; - _pref=" "; - fi - else - if [ "$JID" -eq "$_jid" ]; then - echo -n "$_pref$_npid"; - _pref=" "; - fi + if [ "$JID" -eq "$_jid" ]; + then echo -n "$_pref$_npid"; + _pref=" "; fi ;; esac @@ -670,15 +659,13 @@ run_rc_command() rc_pid= _pidcmd= _procname=${procname:-${command}} - command_interpreter=${command_interpreter:-.} - _leader=${leader:-"NO"} # setup pid check command if [ -n "$_procname" ]; then if [ -n "$pidfile" ]; then _pidcmd='rc_pid=$(check_pidfile '"$pidfile $_procname $command_interpreter"')' else - _pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter $_leader"')' + _pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')' fi if [ -n "$_pidcmd" ]; then _keywords="${_keywords} status poll" -- Christian "naddy" Weisgerber naddy@mips.inka.de