rc.subr exits prematurely
Paul Schmehl
pauls at utdallas.edu
Tue Jul 27 08:10:11 PDT 2004
--On Tuesday, July 27, 2004 03:37:12 PM +0300 Peter Pentchev
<roam at 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 at ringlet.net roam at cnsys.bg roam at 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 at utdallas.edu)
Adjunct Information Security Officer
The University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/ir/security/
More information about the freebsd-rc
mailing list