From 4d647b754e0cbe39c11f13cc5c01b7c097232e92 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 15 Feb 2009 23:21:31 +0200 Subject: [PATCH] init: moved killall and umount logic to rc.shutdown --- initramfs/etc_rc.d_rc.shutdown.sh | 25 +++++++++++++++++++++++++ initramfs/init.sh | 28 +++------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/initramfs/etc_rc.d_rc.shutdown.sh b/initramfs/etc_rc.d_rc.shutdown.sh index 611fd11..96db4c8 100644 --- a/initramfs/etc_rc.d_rc.shutdown.sh +++ b/initramfs/etc_rc.d_rc.shutdown.sh @@ -13,6 +13,13 @@ # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END --- +if [ "x$1" = "x-u" ]; then + do_umount=yes + shift +else + do_umount= +fi + . /etc/rc.d/functions.in title "Stopping services" @@ -23,3 +30,21 @@ status title "Stopping supervisor" check start-stop-daemon -K -s HUP -x /usr/bin/runsvdir status + +for x in TERM:3 KILL:1; do + y="${x%:*}" z="${x#*:}" + title "Sending $y signal to all lingering processes (${z}s)" + check killall5 -s $y + sleep $z + status +done + +if [ -n "$do_umount" ]; then + grep '^/' /proc/mounts | cut -d' ' -f2 | tac | while read x; do + title "Unmounting $x" + check umount -r "$x" + status + done + + umount -ar +fi diff --git a/initramfs/init.sh b/initramfs/init.sh index 229bc1f..619f62d 100644 --- a/initramfs/init.sh +++ b/initramfs/init.sh @@ -3,7 +3,7 @@ # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: target/idunn/initramfs/init.sh -# Copyright (C) 2008 The OpenSDE Project +# Copyright (C) 2008 - 2009 The OpenSDE Project # # More information can be found in the files COPYING and README. # @@ -26,24 +26,7 @@ shutoff_handler() { ln -s / /var/run/init.lock 2> /dev/null || return # stop services - /etc/rc.d/rc.shutdown - - # terminate the rest - sleep 1 - killall5 -s TERM - sleep 2 - - # unmount stuff - grep '^/' /proc/mounts | cut -d' ' -f2 | tac | while read x; do - umount -r "$x" - done - - # kill'em all - killall5 -s KILL - sleep 1 - - # an umount the rest - umount -ar + /etc/rc.d/rc.shutdown -u case "$1" in USR1) halt -f ;; @@ -78,18 +61,13 @@ while true; do /etc/rc.d/rc.shutdown 2>&1 | tee -a $LOG # terminate the rest - sleep 1 - killall5 -s TERM - sleep 2 - killall5 -s KILL - /etc/rc.d/rc.switchroot stop 2>&1 | tee -a $LOG # and proceed exec switch_root -c /dev/console "$rootfs" "$init" $initopt 2>&1 >> $LOG errno=$? - # outch! + # outch! what are we doing here? if [ ! -s $LOG ]; then # the world is gone, time to panic exit $errno