]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
run: Don't try to communicate inner pid for debug shell
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 6 Jul 2024 19:49:19 +0000 (21:49 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 6 Jul 2024 20:12:13 +0000 (22:12 +0200)
The pipe write end has already been closed by then so bash will
fail with "bad file descriptor". Since there's no reason in having
the inner pid in the debug shell let's make sure we don't try to
communicate it there.

mkosi/run.py

index e5ba10f2bd7dd2bcb2e68d14f432a14ea3a23059..9d865ba7a714956a98e42c3f0d7d34b11e492730 100644 (file)
@@ -296,13 +296,14 @@ def spawn(
             os.close(w)
             w = q
             # dash doesn't support working with file descriptors higher than 9 so make sure we use bash.
-            prefix += ["bash", "-c", f"echo $$ >&{w} && exec {w}>&- && exec $0 \"$@\""]
+            innerpidcmd = ["bash", "-c", f"echo $$ >&{w} && exec {w}>&- && exec $0 \"$@\""]
         else:
+            innerpidcmd = []
             r, w = (None, None)
 
         try:
             with subprocess.Popen(
-                [*scope, *prefix, *cmdline],
+                [*scope, *prefix, *innerpidcmd, *cmdline],
                 stdin=stdin,
                 stdout=stdout,
                 stderr=stderr,