Race condition in init.d/functions

Paul G Rogers paul.rogers at juno.com
Sat Dec 2 10:21:54 PST 2006


I found a race condition in LFS-4.1 function killproc(), but the same
code is found in the LFS-6.1.1 I recently installed.  LFS-6.1.1 may
provide a workaround I can't test, but it's still a workaround.

The condition is this: when running Apache, it will spawn a number of
httpd helper daemons, as specified in its config file.  When shutting
httpd down, killproc gets a list of all the httpd daemons, which it is
going to try to kill.  Meanwhile, sending a TERM to the first httpd
daemon will cause it to try kill all its children.  It may successfully
kill some daemons that killproc will later try to kill, and receive an
error.  I suggest killproc should check error codes returned by kill, and
if the pid is already gone, that's acceptable.  

It looks like in LFS-6.1.1 the shutdown script could just kill the first,
and hope it gets all the rest.  But having the shutdown script killing
any stragglers is also appealing.

Paul Rogers  (paul.rogers at juno.com)
http://www.xprt.net/~pgrogers/
http://www.geocities.com/paulgrogers/
Rogers' Second Law: "Everything you do communicates."
(I do not personally endorse any additions after this line. TANSTAAFL 
:-)





More information about the blfs-support mailing list