[techtalk] functions in redhat startup/shutdown scripts
Alex Yan
flare at serv.net
Mon Sep 4 21:01:40 EST 2000
Hey everybody,
I have a question about the redhat startup scripts. I noticed recently
when I rebooted my machine, that the shutdown process was really
slow and that many of the scripts in /etc/rc.d/init.d were reporting a
failure in shutting down. The error message was "kill: no such process
215" (or whatever process id it was). This was happening to a bunch of
the daemons, including httpd, inetd, and nfs.
Anyway, digging in deep, I found that the startup scripts all use
sh functions defined in the file /etc/rc.d/init.d/functions. That file
had a call to ps as follows:
if ps h $pid > /dev/null 2>&1 ; then
# the process(es) is/are still alive
kill $pid
else
# the process(es) is/are dead
fi
and it would do this repeatedly, so that if it wasn't killed the first
time, it would retry.
The problem seemed to be that the "h" option to ps(1) was incompatible
with specifying the process-id to look for. I don't know if this is a
problem with the redhat distribution, the version of ps(1) that I have
(which came with the redhat distribution, but I might have acquired a new
one when I installed a security patch), or with my version of the startup
scripts (again, which came with the redhat distribution, although they
might have been changed by a security patch).
Anybody have any ideas? I have a fix for the /etc/rc.d/init.d/functions
file (*), but I'm curious to know if anybody else has or had this problem
and where the problem came from.
Thanks!
-Alex Yan
flare at serv.net
(*) If you're curious, my fix was to change the ps line from:
ps h $pid > /dev/null 2>&1
to:
ps $pid | grep -v PID >/dev/null 2>&1
because the "grep -v PID" removes the header, which is what the "h"
option is supposed to do.
There are a number of times this "ps h $pid" shows up, so you'll have
to apply the change several times.
More information about the Techtalk
mailing list