Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Dec 2015 16:32:29 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r291770 - head/etc
Message-ID:  <201512041632.tB4GWTJW089011@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Dec  4 16:32:29 2015
New Revision: 291770
URL: https://svnweb.freebsd.org/changeset/base/291770

Log:
  rc.subr: Check for running daemons before a custom start_cmd is executed.
  
  Currently rc scripts implementing their own start_cmd do not enjoy the
  benefits of rc.subr's own check for rc_pid.
  
  This leads to around a third of ports with such a start_cmd not to check for
  the process at all and two thirds of ports to re-implement this check
  (sometimes wrongly).
  
  This patch moves the check for rc_pid to before ${rc_arg}_cmd is executed.
  
  Submitted by:	Dirk Engling
  Reviewed by:	feld
  MFC after:	1 week
  Relnotes:	yes
  Differential Revision:	https://reviews.freebsd.org/D4156

Modified:
  head/etc/rc.subr

Modified: head/etc/rc.subr
==============================================================================
--- head/etc/rc.subr	Fri Dec  4 14:43:53 2015	(r291769)
+++ head/etc/rc.subr	Fri Dec  4 16:32:29 2015	(r291770)
@@ -976,6 +976,14 @@ run_rc_command()
 			fi
 		fi
 
+		if [ $rc_arg = "start" -a -z "$rc_fast" -a -n "$rc_pid" ]; then
+			if [ -z "$rc_quiet" ]; then
+				echo 1>&2 "${name} already running? " \
+				    "(pid=$rc_pid)."
+			fi
+			return 1
+		fi
+
 					# if there's a custom ${XXX_cmd},
 					# run that instead of the default
 					#
@@ -1004,14 +1012,6 @@ run_rc_command()
 			;;
 
 		start)
-			if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
-				if [ -z "$rc_quiet" ]; then
-					echo 1>&2 "${name} already running? " \
-					    "(pid=$rc_pid)."
-				fi
-				return 1
-			fi
-
 			if [ ! -x "${_chroot}${_chroot:+/}${command}" ]; then
 				warn "run_rc_command: cannot run $command"
 				return 1



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