Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jul 2004 10:10:06 -0500
From:      Paul Schmehl <pauls@utdallas.edu>
To:        Peter Pentchev <roam@ringlet.net>, Mike Makonnen <mtm@FreeBSD.org>
Cc:        freebsd-rc@FreeBSD.org
Subject:   Re: rc.subr exits prematurely
Message-ID:  <80748DD218944B5C768B62FC@utd49554.utdallas.edu>
In-Reply-To: <20040727123712.GA1196@straylight.m.ringlet.net>
References:  <20040727123712.GA1196@straylight.m.ringlet.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--On Tuesday, July 27, 2004 03:37:12 PM +0300 Peter Pentchev 
<roam@ringlet.net> wrote:

> Hi,
>
> With the recent changes to rc.subr so that it executes port startup
> scripts in the same shell instead of in a subshell, another problem has
> come up. For the scripts which record a PID file, a check is made on
> startup and on shutdown for the PID file's existence, and if it fails,
> rc.subr exits, which prevents the rest of the scripts from being
> executed.  Attached is a quick patch which works around this problem, but
> may introduce others - I'm not quite sure I understand all of rc.subr's
> internal workings :)
>
Rather than using returns to get around the problem, wouldn't it make more 
sense to check for a PID using ps?  It's entirely possible to have a 
process that's running with no pidfile.

Something like this would work (I've used it before):

if [ -z "$rc_pid" ]; then
  blah
else
  test_pid=`ps -auxw | grep "${name}" | awk '{print $2}'`
  if [ "$test_pid" -gt 0 ]; then
    kill -s HUP "$test_pid"
  else
    echo "${name} not running?"
  fi
fi

> G'luck,
> Peter
>
> --
> Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
> PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
> If I were you, who would be reading this sentence?



Paul Schmehl (pauls@utdallas.edu)
Adjunct Information Security Officer
The University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/ir/security/



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