From: Daan De Meyer Date: Thu, 28 Mar 2024 10:56:35 +0000 (+0100) Subject: Add foreground argument to run() X-Git-Tag: v23~50^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b56af438062492a887b7ddee78c855655fdb2bf;p=thirdparty%2Fmkosi.git Add foreground argument to run() --- diff --git a/mkosi/run.py b/mkosi/run.py index 548ca52e2..d8171db3d 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -145,6 +145,7 @@ def run( log: bool = True, preexec_fn: Optional[Callable[[], None]] = None, sandbox: Sequence[PathString] = (), + foreground: bool = True, ) -> CompletedProcess: sandbox = [os.fspath(x) for x in sandbox] cmdline = [os.fspath(x) for x in cmdline] @@ -180,11 +181,13 @@ def run( stdin = subprocess.DEVNULL def preexec() -> None: - make_foreground_process() + if foreground: + make_foreground_process() if preexec_fn: preexec_fn() if ( + foreground and sandbox and subprocess.run(sandbox + ["sh", "-c", "command -v setpgid"], stdout=subprocess.DEVNULL).returncode == 0 ): @@ -232,7 +235,8 @@ def run( e.cmd = cmdline raise finally: - make_foreground_process(new_process_group=False) + if foreground: + make_foreground_process(new_process_group=False) @contextlib.contextmanager