[projects/pld-builder.new] chroot: kill every process of a user in one place
arekm
arekm at pld-linux.org
Sun Nov 15 01:57:51 CET 2026
commit 5c19d7f3b2688248d5f340810cb040786ebc9834
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Nov 14 23:00:55 2026 +0100
chroot: kill every process of a user in one place
For stopping a build halfway as well as for the leftovers before it, with
the reason never to do it as root next to it.
PLD_Builder/chroot.py | 6 ++++++
PLD_Builder/rpm_builder.py | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/PLD_Builder/chroot.py b/PLD_Builder/chroot.py
index 4fa0b99..f89d7d0 100644
--- a/PLD_Builder/chroot.py
+++ b/PLD_Builder/chroot.py
@@ -56,6 +56,12 @@ def run(cmd, user = "builder", logfile = None, nonet=True):
c = f"{c} >> {logfile} 2>&1"
return subprocess.run(c, check=False, shell=True, stdout=subprocess.DEVNULL).returncode
+def kill_all(user = "builder", logfile = None):
+ """Kill every process of user"""
+ # every process of root is the whole host
+ assert user != "root"
+ run("/bin/kill --verbose -9 -1", user, logfile)
+
def cp(file, outfile, user="builder", rm=False):
cmd = f"cat {file}"
if rm:
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 760d94d..bfbff36 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -178,7 +178,7 @@ def build_rpm(r, b):
b.log_line(f"started at: {time.asctime()}")
b.log_line("killing old processes on a builder")
- chroot.run("/bin/kill --verbose -9 -1", logfile = b.logfile)
+ chroot.kill_all(logfile = b.logfile)
b.log_line("cleaning up /tmp")
chroot.run("rm -rf /tmp/B.*", logfile = b.logfile)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/eda6f4d5bf132e3dd0d7cff6f80b7023fc0402ab
More information about the pld-cvs-commit
mailing list