Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Oct 2007 17:41:59 GMT
From:      Steven Hartland <steven.hartland@multiplay.co.uk>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   conf/117027: rc.subr doesnt deal with perl daemons
Message-ID:  <200710081741.l98Hfx88018882@www.freebsd.org>
Resent-Message-ID: <200710081750.l98Ho28n010585@freefall.freebsd.org>

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

>Number:         117027
>Category:       conf
>Synopsis:       rc.subr doesnt deal with perl daemons
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 08 17:50:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Steven Hartland
>Release:        FreeBSD 6.2-RELEASE-p7 i386
>Organization:
Multiplay
>Environment:
FreeBSD core2.multiplay.co.uk 6.2-RELEASE-p7 FreeBSD 6.2-RELEASE-p7 #1: Thu Aug 2 00:54:23 BST 2007 root@core2.multiplay.co.uk:/usr/src/sys/
i386/compile/MPUK_SMP i386
>Description:
Configuring a rc script to deal with perl daemons currently fails.

This is because the perl daemonization results in a procname of "[perl]" where as the currently the only special case tested is "the basename of the interpreter plus a colon"

Example output:
ps -o "pid,jid,command" -p 60082
  PID    JID COMMAND
60082      0 [perl]
>How-To-Repeat:
Try the mrtg daemon script:
#!/bin/sh
#
# $FreeBSD: ports/net-mgmt/mrtg/files/mrtg_daemon.sh.in,v 1.5 2006/04/23 17:39:52 oliver Exp $

#
# PROVIDE: mrtg_daemon
# REQUIRE: DAEMON bsnmpd snmpd

.  /etc/rc.subr


name="mrtg_daemon"
rcvar=`set_rcvar`

load_rc_config $name

: ${mrtg_daemon_enable="NO"}
: ${mrtg_daemon_pidfile="/var/run/mrtg/mrtg.pid"}
: ${mrtg_daemon_user="mrtg"}
: ${mrtg_daemon_group="mrtg"}
: ${mrtg_daemon_config="/usr/local/etc/mrtg/mrtg.cfg"}

: ${mrtg_daemon_flags="--pid-file $mrtg_daemon_pidfile --lock-file /var/run/mrtg/lockfile --confcache-file /var/run/mrtg/confcache --user $mrtg_daemon_user --group $mrtg_daemon_group --daemon $mrtg_daemon_config"}

start_precmd="mrtg_daemon_precmd"

command="/usr/local/bin/mrtg"
command_interpreter="/usr/local/bin/perl"
pidfile=${mrtg_daemon_pidfile}

mrtg_daemon_precmd()
{
       rm -f /var/run/mrtg/lockfile /var/run/mrtg/confcache $mrtg_daemon_pidfile
}

run_rc_command "$1"
>Fix:
The following patch fixes this behaviour by adding the test for "[perl]" to the valid options:-

--- /etc/rc.subr.orig   Mon Oct  8 18:31:34 2007
+++ /etc/rc.subr        Mon Oct  8 18:32:31 2007
@@ -271,5 +271,5 @@
                _fp_args='_argv'
                _fp_match='case "$_argv" in
-                   ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)'
+                   ${_interp}|"${_interp} "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)'
        else                                    # a normal daemon
                _procnamebn=${_procname##*/}

Patch attached with submission follows:

--- /etc/rc.subr.orig	Mon Oct  8 18:31:34 2007
+++ /etc/rc.subr	Mon Oct  8 18:32:31 2007
@@ -271,5 +271,5 @@
 		_fp_args='_argv'
 		_fp_match='case "$_argv" in
-		    ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)'
+		    ${_interp}|"${_interp} "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)'
 	else					# a normal daemon
 		_procnamebn=${_procname##*/}


>Release-Note:
>Audit-Trail:
>Unformatted:



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