Commit b584b60c authored by Tails developers's avatar Tails developers
Browse files

Use helper function.

parent 54c4ac55
......@@ -7,27 +7,18 @@
# Import windows_camouflage_is_enabled()
. /usr/local/lib/tails-shell-library/tails-greeter.sh
# Import try_for().
. /usr/local/lib/tails-shell-library/common.sh
# Break down the chroot and kill all of its processes
try_cleanup_browser_chroot () {
local chroot="${1}"
local cow="${2}"
local user="${3}"
local counter=0
local ret=0
while [ "${counter}" -le 10 ] && pgrep -u ${user} 1>/dev/null 2>&1; do
pkill -u ${user} 1>/dev/null 2>&1
ret=${?}
sleep 1
counter=$((${counter}+1))
done
[ ${ret} -eq 0 ] || pkill -9 -u ${user} 1>/dev/null 2>&1
try_for 10 "pkill -u ${user} 1>/dev/null 2>&1" || \
pkill -9 -u ${user} 1>/dev/null 2>&1
for mnt in ${chroot}/dev ${chroot}/proc ${chroot} ${cow}; do
counter=0
while [ "${counter}" -le 10 ] && mountpoint -q ${mnt} 2>/dev/null; do
umount ${mnt} 2>/dev/null
sleep 1
counter=$((${counter}+1))
done
try_for 10 "umount ${mnt} 2>/dev/null"
done
rmdir ${cow} ${chroot} 2>/dev/null
}
......
......@@ -14,3 +14,9 @@ wait_until() {
done
return 0
}
# Just an alias. The second argument (wait_until()'s check_expr) is
# the "try code block".
try_for() {
wait_until "${@}"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment