|
Harald Hoyer |
fe68ba |
From df6bb5e959178cba06118493a7c8d019e84d54e7 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
fe68ba |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
fe68ba |
Date: Tue, 15 May 2018 13:37:53 +0200
|
|
Harald Hoyer |
fe68ba |
Subject: [PATCH] shutdown: sleep a little, if a process was killed
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
If a process (maybe plymouth) was still pinning /oldroot, then shutdown
|
|
Harald Hoyer |
fe68ba |
would
|
|
Harald Hoyer |
fe68ba |
- kill -9 $pid
|
|
Harald Hoyer |
fe68ba |
- umount_a
|
|
Harald Hoyer |
fe68ba |
- umount_a
|
|
Harald Hoyer |
fe68ba |
in a very short timeframe. A small sleep hopefully lets the scheduler free
|
|
Harald Hoyer |
fe68ba |
up /oldroot in the mean time.
|
|
Harald Hoyer |
fe68ba |
---
|
|
Harald Hoyer |
fe68ba |
modules.d/99base/dracut-lib.sh | 7 ++++++-
|
|
Harald Hoyer |
fe68ba |
modules.d/99shutdown/module-setup.sh | 2 +-
|
|
Harald Hoyer |
fe68ba |
modules.d/99shutdown/shutdown.sh | 2 +-
|
|
Harald Hoyer |
fe68ba |
3 files changed, 8 insertions(+), 3 deletions(-)
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
fe68ba |
index 99cb9dbc..b78272a3 100755
|
|
Harald Hoyer |
fe68ba |
--- a/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
fe68ba |
+++ b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
fe68ba |
@@ -118,6 +118,7 @@ str_replace() {
|
|
Harald Hoyer |
fe68ba |
killall_proc_mountpoint() {
|
|
Harald Hoyer |
fe68ba |
local _pid
|
|
Harald Hoyer |
fe68ba |
local _t
|
|
Harald Hoyer |
fe68ba |
+ local _killed=0
|
|
Harald Hoyer |
fe68ba |
for _pid in /proc/*; do
|
|
Harald Hoyer |
fe68ba |
_pid=${_pid##/proc/}
|
|
Harald Hoyer |
fe68ba |
case $_pid in
|
|
Harald Hoyer |
fe68ba |
@@ -125,8 +126,12 @@ killall_proc_mountpoint() {
|
|
Harald Hoyer |
fe68ba |
esac
|
|
Harald Hoyer |
fe68ba |
[ -e "/proc/$_pid/exe" ] || continue
|
|
Harald Hoyer |
fe68ba |
[ -e "/proc/$_pid/root" ] || continue
|
|
Harald Hoyer |
fe68ba |
- strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" && kill -9 "$_pid"
|
|
Harald Hoyer |
fe68ba |
+ if strstr "$(ls -l -- "/proc/$_pid" "/proc/$_pid/fd" 2>/dev/null)" "$1" ; then
|
|
Harald Hoyer |
fe68ba |
+ kill -9 "$_pid"
|
|
Harald Hoyer |
fe68ba |
+ _killed=1
|
|
Harald Hoyer |
fe68ba |
+ fi
|
|
Harald Hoyer |
fe68ba |
done
|
|
Harald Hoyer |
fe68ba |
+ return $_killed
|
|
Harald Hoyer |
fe68ba |
}
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
getcmdline() {
|
|
Harald Hoyer |
fe68ba |
diff --git a/modules.d/99shutdown/module-setup.sh b/modules.d/99shutdown/module-setup.sh
|
|
Harald Hoyer |
fe68ba |
index 5cb3594a..dfd6caa2 100755
|
|
Harald Hoyer |
fe68ba |
--- a/modules.d/99shutdown/module-setup.sh
|
|
Harald Hoyer |
fe68ba |
+++ b/modules.d/99shutdown/module-setup.sh
|
|
Harald Hoyer |
fe68ba |
@@ -14,7 +14,7 @@ depends() {
|
|
Harald Hoyer |
fe68ba |
# called by dracut
|
|
Harald Hoyer |
fe68ba |
install() {
|
|
Harald Hoyer |
fe68ba |
local _d
|
|
Harald Hoyer |
fe68ba |
- inst_multiple umount poweroff reboot halt losetup stat
|
|
Harald Hoyer |
fe68ba |
+ inst_multiple umount poweroff reboot halt losetup stat sleep
|
|
Harald Hoyer |
fe68ba |
inst_multiple -o kexec
|
|
Harald Hoyer |
fe68ba |
inst "$moddir/shutdown.sh" "$prefix/shutdown"
|
|
Harald Hoyer |
fe68ba |
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
|
|
Harald Hoyer |
fe68ba |
diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh
|
|
Harald Hoyer |
fe68ba |
index 918a8a4f..f21cc811 100755
|
|
Harald Hoyer |
fe68ba |
--- a/modules.d/99shutdown/shutdown.sh
|
|
Harald Hoyer |
fe68ba |
+++ b/modules.d/99shutdown/shutdown.sh
|
|
Harald Hoyer |
fe68ba |
@@ -38,7 +38,7 @@ source_hook pre-shutdown
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
warn "Killing all remaining processes"
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
-killall_proc_mountpoint /oldroot
|
|
Harald Hoyer |
fe68ba |
+killall_proc_mountpoint /oldroot || sleep 0.2
|
|
Harald Hoyer |
fe68ba |
|
|
Harald Hoyer |
fe68ba |
umount_a() {
|
|
Harald Hoyer |
fe68ba |
local _did_umount="n"
|