]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
shutdown: sleep a little, if a process was killed
authorHarald Hoyer <harald@redhat.com>
Tue, 15 May 2018 11:37:53 +0000 (13:37 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 15 May 2018 11:37:53 +0000 (13:37 +0200)
If a process (maybe plymouth) was still pinning /oldroot, then shutdown
would
- kill -9 $pid
- umount_a
- umount_a
in a very short timeframe. A small sleep hopefully lets the scheduler free
up /oldroot in the mean time.

modules.d/99base/dracut-lib.sh
modules.d/99shutdown/module-setup.sh
modules.d/99shutdown/shutdown.sh

index 99cb9dbc6a1e8926ae4188495783bf39a2bcffb6..b78272a31af75c37e917e1b1036f130bc26dabfa 100755 (executable)
@@ -118,6 +118,7 @@ str_replace() {
 killall_proc_mountpoint() {
     local _pid
     local _t
+    local _killed=0
     for _pid in /proc/*; do
         _pid=${_pid##/proc/}
         case $_pid in
@@ -125,8 +126,12 @@ killall_proc_mountpoint() {
         esac
         [ -e "/proc/$_pid/exe" ] || continue
         [ -e "/proc/$_pid/root" ] || continue
-        strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" && kill -9 "$_pid"
+        if strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" ; then
+            kill -9 "$_pid"
+            _killed=1
+        fi
     done
+    return $_killed
 }
 
 getcmdline() {
index 5cb3594a891fbfcf8b57822d879150ed814652d3..dfd6caa200332e0091170a12d537627501d695f6 100755 (executable)
@@ -14,7 +14,7 @@ depends() {
 # called by dracut
 install() {
     local _d
-    inst_multiple umount poweroff reboot halt losetup stat
+    inst_multiple umount poweroff reboot halt losetup stat sleep
     inst_multiple -o kexec
     inst "$moddir/shutdown.sh" "$prefix/shutdown"
     [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
index 918a8a4f123578e39f38404670d5cbe3e3436bb3..f21cc811b512f457efe7bc33c84b73926af100ef 100755 (executable)
@@ -38,7 +38,7 @@ source_hook pre-shutdown
 
 warn "Killing all remaining processes"
 
-killall_proc_mountpoint /oldroot
+killall_proc_mountpoint /oldroot || sleep 0.2
 
 umount_a() {
     local _did_umount="n"