On 2014-06-02, Tomek Wałaszek <tmwalas...@gmail.com> 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                          na...@mips.inka.de
_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to