Hello,
i have encountered problems using initscripts to stop self-forking
daemons like "Apache".
Normally i would use "killproc httpd" to do this.
This (mostly) don't work, because the function "killproc" uses the
pidlist returned by "getpids" and this will use "pidof" utility to
obtain process-ids of all running instances of "httpd".
If you're lucky, the first pid in the list is the masters pid and
killing it, would also kill all childs. But if the first pid is only
a child, httpd will immediatly re-fork another one, after killing it.
So i changed the "getpids" function to:
------------------------------------------------------------------------
----
# Returns all of the pid #'s for $1 process in global "$pidlist"
getpids()
{
base=${1##*/}
local lpids=""
local pid
local masterpid
pidlist=""
# look for pidfile first
if [ -f /var/run/$base.pid ]
then
masterpid=$(cat /var/run/$base.pid 2>/dev/null)
pidlist="$masterpid"
fi
# get all child pids
lpids=$(pidof $base)
for pid in $lpids
do
if [ $pid -ne $$ ] && [ $pid -ne $PPID ] && [ $pid -ne
$masterpid ]
then
pidlist="$pidlist $pid"
fi
done
}
------------------------------------------------------------------------
----
This ensures the master-pid (if any) will preceed the list, and so if
the master get killed, it would kill all of its childs himself.
Maybe someone could change this in the global distribution files of LFS.
Mit freundlichen Grüssen,
Oliver Geisen
_____________________________
Systemadministrator
Kreisboten Verlag Mühlfellner KG
82362 Weilheim i. Ob.
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page