Here is a dumb python program where the issue happens:
import signal
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
def interrupt():
s = input("test")
print(s)
loop.stop()
loop.add_signal_handler(signal.SIGINT, interrupt)
loop.run_forever()
loop.remove_signal_handler(signal.SIGINT)
loop.close()
On host, running this program, then pressing ctrl+c, a prompt shows up, then I can type some text and enter. The text is printed again and the program exits.
Now, if I run through bwrap --ro-bind / / -- /usr/bin/python3 test.py, I get the error:
handle: <Handle interrupt() at test-interrupt.py:7>
Traceback (most recent call last):
File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
File "test-interrupt.py", line 8, in interrupt
s = input("test")
EOFError
This is because is bwrap is part of foreground process group. Instead it should be the child process as to be the foreground process group.
Here is a dumb python program where the issue happens:
On host, running this program, then pressing ctrl+c, a prompt shows up, then I can type some text and enter. The text is printed again and the program exits.
Now, if I run through
bwrap --ro-bind / / -- /usr/bin/python3 test.py, I get the error:This is because is bwrap is part of foreground process group. Instead it should be the child process as to be the foreground process group.