From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, targets/support/
Date: Thu, 29 Oct 2020 16:34:49 +0000 (UTC) [thread overview]
Message-ID: <1603989280.f4798bf3ddb111d76d8b54201c1b50cbf51e8d93.mattst88@gentoo> (raw)
commit: f4798bf3ddb111d76d8b54201c1b50cbf51e8d93
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:19:09 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:34:40 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f4798bf3
catalyst: Remove kill_support_pids()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
Now that the build sequence is executed in its own mount namespace, the
mounts are implicitly unmounted when the last process in the namespace
dies, meaning we don't need to try any funny business around cleaning up
processes in order to unmount.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 30 +++---------------
targets/support/kill-chroot-pids.sh | 62 -------------------------------------
2 files changed, 4 insertions(+), 88 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index caec5935..bd5ba8d0 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -638,17 +638,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
assert self.settings[verify] == "blake2"
self.settings.setdefault("gk_mainargs", []).append("--b2sum")
- def kill_chroot_pids(self):
- log.info('Checking for processes running in chroot and killing them.')
-
- # Force environment variables to be exported so script can see them
- self.setup_environment()
-
- killcmd = normpath(self.settings["sharedir"] +
- self.settings["shdir"] + "/support/kill-chroot-pids.sh")
- if os.path.exists(killcmd):
- cmd([killcmd], env=self.env)
-
def mount_safety_check(self):
"""
Check and verify that none of our paths in mypath are mounted. We don't
@@ -920,18 +909,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cxt = libmount.Context(target=str(target))
cxt.umount()
- except OSError:
- log.warning('First attempt to unmount failed: %s', target)
- log.warning('Killing any pids still running in the chroot')
-
- self.kill_chroot_pids()
-
- try:
- cxt.umount()
- except OSError as e:
- umount_failed = True
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
+ except OSError as e:
+ log.warning("Couldn't umount: %s, %s", target,
+ e.strerror)
+ umount_failed = True
if umount_failed:
# if any bind mounts really failed, then we need to raise
@@ -1382,9 +1363,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def run(self):
self.chroot_lock.write_lock()
- # Kill any pids in the chroot
- self.kill_chroot_pids()
-
# Check for mounts right away and abort if we cannot unmount them
self.mount_safety_check()
diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh
deleted file mode 100755
index ea8ee402..00000000
--- a/targets/support/kill-chroot-pids.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Script to kill processes found running in the chroot.
-
-if [ "${clst_chroot_path}" == "/" ]
-then
- echo "Aborting .... clst_chroot_path is set to /"
- echo "This is very dangerous"
- exit 1
-fi
-
-if [ "${clst_chroot_path}" == "" ]
-then
- echo "Aborting .... clst_chroot_path is NOT set"
- echo "This is very dangerous"
- exit 1
-fi
-
-j=0
-declare -a pids
-# Get files and dirs in /proc
-for i in `ls /proc`
-do
- # Test for directories
- if [ -d /proc/$i ]
- then
- # Search for exe containing string inside ${clst_chroot_path}
- ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null
-
- # If found
- if [ $? == 0 ]
- then
- # Assign the pid into the pids array
- pids[$j]=$i
- j=$(($j+1))
- fi
- fi
-done
-
-if [ ${j} -gt 0 ]
-then
- echo
- echo "Killing process(es)"
- echo "pid: process name"
- for pid in ${pids[@]}
- do
- P_NAME=$(ls -la --color=never /proc/${pid} 2>&1 |grep exe|grep ${clst_chroot_path}|awk '{print $11}')
- echo ${pid}: ${P_NAME}
- done
- echo
- echo "Press Ctrl-C within 10 seconds to abort"
-
- sleep 10
-
- for pid in ${pids[@]}
- do
- kill -9 ${pid}
- done
-
- # Small sleep here to give the process(es) a chance to die before running unbind again.
- sleep 5
-
-fi
next reply other threads:[~2020-10-29 16:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 16:34 Matt Turner [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-12-27 23:15 [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, targets/support/ Matt Turner
2021-01-18 19:53 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-10-29 19:05 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-22 18:59 Matt Turner
2020-10-22 18:06 Matt Turner
2020-05-20 3:39 Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1603989280.f4798bf3ddb111d76d8b54201c1b50cbf51e8d93.mattst88@gentoo \
--to=mattst88@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox