Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: build/install-chroot.sh

Issue 20010003: We sometimes erroneously detected processes in other sessions as belonging to our session. Conseque… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/install-chroot.sh
diff --git a/build/install-chroot.sh b/build/install-chroot.sh
index 155fc798b267237fad721a423b15a9e83c1b7f7e..0ef33d277cfcf152d6611781879ad4e8b57f76fa 100755
--- a/build/install-chroot.sh
+++ b/build/install-chroot.sh
@@ -498,6 +498,7 @@ while [ "$#" -ne 0 ]; do
done
session="$(schroot -c "${chroot}" -b)"
+export CHROOT_SESSION_ID="${session}"
if [ $# -eq 0 ]; then
schroot -c "${session}" -r -p
@@ -509,13 +510,33 @@ rc=$?
i=$(schroot -c "${session}" -r -p ls -- -id /proc/self/root/. |
awk '{ print $1 }') 2>/dev/null
+other_pids=
while [ -n "$i" ]; do
- pids=$(ls -id1 /proc/*/root/. 2>/dev/null |
+ pids=$({ ls -id1 /proc/*/root/. 2>/dev/null |
jln (very slow on Chromium) 2013/07/23 00:41:20 Add a comment to explain the set substraction magi
sed -e 's,^[^0-9]*'$i'.*/\([1-9][0-9]*\)/.*$,\1,
t
- d') >/dev/null 2>&1
- [ -z "$pids" ] && break
- kill -9 $pids
+ d';
+ echo "${other_pids}";
+ echo "${other_pids}"; } | sort | uniq -u) >/dev/null 2>&1
+ # Kill all processes that are still left running in the session. This is
+ # typically an assortment of daemon processes that were started
+ # automatically. They result in us being unable to tear down the session
+ # cleanly.
+ [ -z "${pids}" ] && break
+ for j in $pids; do
+ # Unfortunately, the way that schroot sets up sessions has the
+ # side-effect of being unable to tell one session apart from another.
+ # This can result in us attempting to kill processes in other sessions.
+ # We make a best-effort to avoid doing so.
+ k="$( ( xargs -0 -n1 </proc/$j/environ ) 2>/dev/null |
+ sed 's/^CHROOT_SESSION_ID=/x/;t1;d;:1;q')"
+ if [ -n "${k}" -a "${k#x}" != "${session}" ]; then
+ other_pids="${other_pids}
+${j}"
+ continue
+ fi
+ kill -9 $pids
+ done
done
schroot -c "${session}" -e
exit $rc
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698