From: Daan De Meyer Date: Mon, 25 Sep 2023 11:00:52 +0000 (+0200) Subject: Use setpgid if available X-Git-Tag: v18~40^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1922%2Fhead;p=thirdparty%2Fmkosi.git 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. --- 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