From owner-freebsd-bugs@FreeBSD.ORG Thu May 4 11:50:18 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 07C1216A404 for ; Thu, 4 May 2006 11:50:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 53F0143D48 for ; Thu, 4 May 2006 11:50:17 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k44BoHZU053901 for ; Thu, 4 May 2006 11:50:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k44BoHlA053900; Thu, 4 May 2006 11:50:17 GMT (envelope-from gnats) Resent-Date: Thu, 4 May 2006 11:50:17 GMT Resent-Message-Id: <200605041150.k44BoHlA053900@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Richard Brooksby Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 668D916A400 for ; Thu, 4 May 2006 11:48:03 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3299D43D45 for ; Thu, 4 May 2006 11:48:03 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k44Bm25k016527 for ; Thu, 4 May 2006 11:48:02 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k44Bm221016526; Thu, 4 May 2006 11:48:02 GMT (envelope-from nobody) Message-Id: <200605041148.k44Bm221016526@www.freebsd.org> Date: Thu, 4 May 2006 11:48:02 GMT From: Richard Brooksby To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: misc/96766: run_rc_command doesn't work for Python scripts X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2006 11:50:18 -0000 >Number: 96766 >Category: misc >Synopsis: run_rc_command doesn't work for Python scripts >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: Thu May 04 11:50:16 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Richard Brooksby >Release: 6.0-RELEASE-p6 >Organization: Ravenbrook Limited >Environment: FreeBSD raven.ravenbrook.com 6.0-RELEASE-p6 FreeBSD 6.0-RELEASE-p6 #0: Tue Apr 11 13:52:12 BST 2006 root@coot.verity-networks.com:/usr/obj/usr/src/sys/GENERIC i386 >Description: The run_rc_command from /etc/rc.subr is intended to lift out the repetetive parts of starting and stopping system daemons. However, it fails to work on Python scripted daemons which start with the usual #! line: #!/usr/bin/env python Although it will start a daemon, it can't stop, restart, or report its status. This gives failures like: raven# sh /usr/local/etc/rc.d/py-spamass-milter.sh status py_spamass_milter is not running. even though raven# ps -p `cat /var/run/spamd/py-spamass-milter.pid` PID TT STAT TIME COMMAND 75992 ?? Ss 1:55.69 python /usr/local/sbin/py-spamass-milter -p /var/run/spamd/py-spamass-milter.sock Setting the "interpreter" variable before calling run_rc_command doesn't help. I think the run_rc_command function might be assuming that the interpreter will appear immediately after the #! in the script itself. This won't just affect Python: there are other systems which use "env" in the same way. >How-To-Repeat: Create a simple daemon in a Python executable script, and a corresponding file in /usr/local/etc/rc.d, then try to stop or restart the daemon. >Fix: The rc_command function does a lot of work to make sure it's not going to kill the wrong process, but its assumptions about what will come out of "ps" are wrong, and probably too paranoid? Perhaps a simpler check would be fine. >Release-Note: >Audit-Trail: >Unformatted: