diff options
author | kris <kris@FreeBSD.org> | 2006-02-11 10:05:01 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2006-02-11 10:05:01 +0000 |
commit | 9ec05089ce3a6c5e2d50418c9a61805aa974a5dd (patch) | |
tree | 69533f2a359cc03e59847d9a17376811d28866c3 /Tools/portbuild | |
parent | 7023f038811c88ad1222cfeda57b5e08c9ffc4fe (diff) | |
download | FreeBSD-ports-9ec05089ce3a6c5e2d50418c9a61805aa974a5dd.zip FreeBSD-ports-9ec05089ce3a6c5e2d50418c9a61805aa974a5dd.tar.gz |
* In kill_procs(), pass in the directory and mountpoint as separate
arguments (cosmetic)
* Detect if a chroot was used to run a jailed build, and first attempt
to gracefully shut it down by killing everything within using pgrep(1)
This has a much higher chance of succeeding that relying on fstat to
identify processes that might interfere with our attempts to clean up
mountpoints, which is fragile (libkvm-dependent), and inherently
unreliable at best.
Diffstat (limited to 'Tools/portbuild')
-rwxr-xr-x | Tools/portbuild/scripts/clean-chroot | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Tools/portbuild/scripts/clean-chroot b/Tools/portbuild/scripts/clean-chroot index a722384..24491e9 100755 --- a/Tools/portbuild/scripts/clean-chroot +++ b/Tools/portbuild/scripts/clean-chroot @@ -3,10 +3,11 @@ kill_procs() { dir=$1 + mount=$2 pids="XXX" while [ ! -z "${pids}" ]; do - pids=$(fstat -f "$dir" | tail +2 | awk '{print $3}' | sort -u) + pids=$(fstat -f "${dir}${mount}" | tail +2 | awk '{print $3}' | sort -u) if [ ! -z "${pids}" ]; then echo "Killing off pids in ${dir}" ps -p $pids @@ -26,7 +27,7 @@ cleanup_mount() { umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!" fi if [ "${mdir}" = "${chroot}${mount}" ]; then - kill_procs ${chroot}${mount} + kill_procs ${chroot} ${mount} umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!" fi fi @@ -55,6 +56,11 @@ if [ `realpath ${chroot}` = "/" ]; then exit 1 fi +if [ -f ${chroot}/tmp/jail.id ]; then + pgrep -lfj `awk '{print $1}' ${chroot}/tmp/jail.id` + pkill -j `awk '{print $1}' ${chroot}/tmp/jail.id` +fi + #umount ${chroot}/proc if [ ${arch} = "i386" ]; then |