sysupgrade: Enable killing of all processes under upgraded

If the sysupgrade scripts is called under upgraded, it will not kill all
other processes as it should to avoid interference by locked filesystem.
This patch checks the parent and if it is upgraded, it kills all.

Signed-off-by: André Valentin <avalentin@marcant.net>

SVN-Revision: 41563
lede-17.01
John Crispin 2014-07-10 19:16:27 +00:00
parent f8f6678574
commit be26421f45
1 changed files with 26 additions and 11 deletions

View File

@ -99,6 +99,13 @@ kill_remaining() { # [ <signal> ]
local sig="${1:-TERM}" local sig="${1:-TERM}"
echo -n "Sending $sig to remaining processes ... " echo -n "Sending $sig to remaining processes ... "
local my_pid=$$
local my_ppid=$(cut -d' ' -f4 /proc/$my_pid/stat)
local my_ppisupgraded=
grep -q upgraded /proc/$my_ppid/cmdline >/dev/null && {
local my_ppisupgraded=1
}
local stat local stat
for stat in /proc/[0-9]*/stat; do for stat in /proc/[0-9]*/stat; do
[ -f "$stat" ] || continue [ -f "$stat" ] || continue
@ -113,9 +120,16 @@ kill_remaining() { # [ <signal> ]
# Skip kernel threads # Skip kernel threads
[ -n "$cmdline" ] || continue [ -n "$cmdline" ] || continue
if [ $$ -eq 1 ] || [ $my_ppid -eq 1 ] && [ -n "$my_ppisupgraded" ]; then
# Running as init process, kill everything except me
if [ $pid -ne $$ ] && [ $pid -ne $my_ppid ]; then
echo -n "$name "
kill -$sig $pid 2>/dev/null
fi
else
case "$name" in case "$name" in
# Skip essential services # Skip essential services
*procd*|*upgraded*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*|*nas*) : ;; *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*|*nas*) : ;;
# Killable process # Killable process
*) *)
@ -125,6 +139,7 @@ kill_remaining() { # [ <signal> ]
fi fi
;; ;;
esac esac
fi
done done
echo "" echo ""
} }