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.
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,