Skip to content

Commit

Permalink
_sandboxbuildboxrun.py: Restore terminal after exit of interactive child
Browse files Browse the repository at this point in the history
This is a port of 8f40112 to the
buildbox-run sandbox

Fixes #1690
  • Loading branch information
abderrahim committed May 21, 2024
1 parent db0a4f3 commit 793405c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/buildstream/sandbox/_sandboxbuildboxrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ def resume_proc():
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))

Expand Down

0 comments on commit 793405c

Please sign in to comment.