diff --git a/mock/py/mock.py b/mock/py/mock.py index 00e9e2421..70df4663f 100755 --- a/mock/py/mock.py +++ b/mock/py/mock.py @@ -800,7 +800,7 @@ def main(): options="private")) buildroot.mounts.bootstrap_mounts.append( BindMountPoint(buildroot.make_chroot_path(), inner_mount, - recursive=True, options="private")) + recursive=True, options="private").treat_as_chroot()) signal.signal(signal.SIGTERM, partial(handle_signals, buildroot)) signal.signal(signal.SIGPIPE, partial(handle_signals, buildroot)) diff --git a/mock/py/mockbuild/mounts.py b/mock/py/mockbuild/mounts.py index 91e328045..40d38c657 100644 --- a/mock/py/mockbuild/mounts.py +++ b/mock/py/mockbuild/mounts.py @@ -19,6 +19,15 @@ def __init__(self, mountsource, mountpath): self.mountpath = mountpath self.mountsource = mountsource self.mounted = None + self._is_chroot = False + + def treat_as_chroot(self): + """ + If we use this directory as chroot, we might want to do special + actions while mounting and unmounting. + """ + self._is_chroot = True + return self @traceLog() # pylint: disable=unused-argument @@ -28,6 +37,12 @@ def umount(self, force=False, nowarn=False): """ if not self.mounted: return None + + if self._is_chroot: + # Don't keep background processes running with unmounted + # /proc/self/root directory. + util.orphansKill(self.mountpath) + if self._do_umount(): self.mounted = False return True