Subject: pkg/36028: cat not stopping use mail/postgrey rc.d file
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <ishit@oak.dti.ne.jp>
List: pkgsrc-bugs
Date: 03/18/2007 12:45:01
>Number:         36028
>Category:       pkg
>Synopsis:       cat not stopping use mail/postgrey rc.d file
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 18 12:45:01 +0000 2007
>Originator:     ISIHARA Takanori
>Release:        NetBSD/amd64 2.0.3
>Organization:
Nagoya *BSD Users' Group :-)
>Environment:
NetBSD search.ombudsman.jp 2.0.3_STABLE NetBSD 2.0.3_STABLE (GENERIC.user64) #0: Sat Apr 15 11:34:15 JST 2006  root@search.ombudsman.jp:/opt/src-2-0/sys/arch/amd64/compile/obj/GENERIC.user64 amd64

>Description:
I cat not stopping use mail/postgrey rc.d file.

It seems PR pkg/35334 same problem.
and other Net::Server perl module use packages have this problem. I think.

>How-To-Repeat:
/etc/rc.d/postgrey stop

>Fix:
--- files/postgrey.sh.orig      2004-12-23 00:51:38.000000000 +0900
+++ files/postgrey.sh   2007-03-18 21:30:50.000000000 +0900
@@ -21,5 +21,25 @@
 "
 @PKGBASE@_flags=${@PKGBASE@_flags-"-i 2525"}

+stop_cmd="postgrey_stop"
+
+# Net::Server breaks rc.subr's techniques for detecting whether the
+# process running at a certain PID is actually the process we wish to
+# stop.  Just unconditionally send SIGTERM to the PID instead.
+#
+postgrey_stop()
+{
+      @ECHO@ "Stopping ${name}."
+      if [ -f ${pidfile} ]; then
+              pid=`@HEAD@ -1 ${pidfile}`
+              doit="kill ${pid}"
+              if ! eval $doit && [ -z "$rc_force" ]; then
+                      return 1
+              fi
+              wait_for_pids $pid
+      fi
+      @RM@ -f ${pidfile}
+}
+
 load_rc_config $name
 run_rc_command "$1"