From 4d0459a6989083199ec86bc5f917bb6c99f49389 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 25 Sep 2023 13:00:52 +0200 Subject: [PATCH] Use setpgid if available The next release of util-linux will include setpgid which has a --foreground option that does exactly the same as our foreground() function. This new utility allows us to make the processes executed by bubblewrap the foreground process, which makes sure that SIGINT isn't intercepted by bwrap. --- mkosi/run.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mkosi/run.py b/mkosi/run.py index d4b5595fc..71d6fbcda 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -346,6 +346,9 @@ def bwrap( "sh", "-c", "chmod 1777 /dev/shm && exec $0 \"$@\"", ] + if setpgid := find_binary("setpgid"): + cmdline += [setpgid, "--foreground"] + try: result = run([*cmdline, *cmd], env=env, log=False, stdin=stdin, stdout=stdout, input=input) except subprocess.CalledProcessError as e: @@ -394,6 +397,9 @@ def apivfs_cmd(root: Path) -> list[PathString]: "--unsetenv", "TMPDIR", ] + if setpgid := find_binary("setpgid"): + cmdline += [setpgid, "--foreground"] + if (root / "etc/machine-id").exists(): # Make sure /etc/machine-id is not overwritten by any package manager post install scripts. cmdline += ["--ro-bind", root / "etc/machine-id", root / "etc/machine-id"] @@ -435,6 +441,9 @@ def chroot_cmd(root: Path, *, options: Sequence[PathString] = ()) -> list[PathSt *options, ] + if setpgid := find_binary("setpgid", root): + cmdline += [setpgid, "--foreground"] + return apivfs_cmd(root) + cmdline -- 2.47.2