This is an automated email from the ASF dual-hosted git repository. akitouni pushed a commit to branch abderrahim/background in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 66ec67cbc5d9cee1673b3659a98cddae077eacb7 Author: Abderrahim Kitouni <[email protected]> AuthorDate: Sat Nov 5 12:18:46 2022 +0100 _sandboxbuildboxrun.py: Restore terminal after exit of interactive child This is a port of 8f401127c450ea1c2a1e2878d2ac28a7166d355c to the buildbox-run sandbox Fixes #1690 --- src/buildstream/sandbox/_sandboxbuildboxrun.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py index 1987ebac1..3a82e4d11 100644 --- a/src/buildstream/sandbox/_sandboxbuildboxrun.py +++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py @@ -223,6 +223,18 @@ class SandboxBuildBoxRun(SandboxREAPI): except psutil.NoSuchProcess: pass + if interactive: + # Make this process the foreground process again, otherwise the + # next read() on stdin will trigger SIGTTIN and stop the process. + # This is required because the sandboxed process does not have + # permission to do this on its own (running in separate PID namespace). + # + # tcsetpgrp() will trigger SIGTTOU when called from a background + # process, so ignore it temporarily. + handler = signal.signal(signal.SIGTTOU, signal.SIG_IGN) + os.tcsetpgrp(0, os.getpid()) + signal.signal(signal.SIGTTOU, handler) + if returncode != 0: raise SandboxError("buildbox-run failed with returncode {}".format(returncode))
