[cfr] rc.shutdown patch

Bjoern A. Zeeb bzeeb-lists at lists.zabbadoz.net
Mon Jan 5 09:45:07 PST 2009


Hi,

while starting and stopping jails with rc.d/jail on a system that had
no killall in the base (very stripped /usr/**) I found that unmounting
devfs for the jail hadn't worked.

Digging into this I found that rc.shutdown lets a sleep 30 (rcshutdown_timeout) 
hanging around for the rest of that time which is unpleasent if it could go
away cleanly.

I am using pkill, which is in /bin/ as well, to kill the sleep and
the subshell instead of only killing the subshell and leaving the
sleep hanging re-parented to init.

I'd like to commit this but am a bit unsure for adding pkill
dependency to such a central rc file; Though, two startup scripts
seem to use it already (*ppp*) and dhclient uses 'pgrep' which is
the same inode.

I have a patch here:
http://people.freebsd.org/~bz/20090105-03-rc-shutdown.diff

! 
! Instead of killing the 'watchdog' subshell and leaving
! a sleep for the timeout, make sure all goes away cleanly.
! 
! This avoids needing killall in rc.d/jail for a clean shutdown
! and generally does not leave dangling processes on shutdown that
! something else has to kill.
! 
Index: etc/rc.shutdown
===================================================================
--- etc/rc.shutdown	(revision 186775)
+++ etc/rc.shutdown	(working copy)
@@ -98,7 +98,7 @@
  # Terminate the background watchdog timer (if it is running)
  #
  if [ -n "$_rcshutdown_watchdog" ]; then
-	kill -TERM $_rcshutdown_watchdog >/dev/null 2>&1
+	pkill -TERM -P $_rcshutdown_watchdog >/dev/null 2>&1
  fi

  # Insert other shutdown procedures here


Footnote: for jails we will want to keep the killall for other reasons
(as we usually cannot trust the admin inside the jail to get a clean
shutdown working).

Any comments?

/bz

-- 
Bjoern A. Zeeb                      The greatest risk is not taking one.


More information about the freebsd-current mailing list