[cfr] rc.shutdown patch

From: Bjoern A. Zeeb <bzeeb-lists_at_lists.zabbadoz.net>
Date: Mon, 5 Jan 2009 17:43:38 +0000 (UTC)
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)
_at__at_ -98,7 +98,7 _at__at_
  # 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.
Received on Mon Jan 05 2009 - 16:45:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:40 UTC