wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.29k stars 516 forks source link

MainLoop not handling SIGINT in containerized application #2406

Open Apteryks opened 1 year ago

Apteryks commented 1 year ago

Describe the bug: A minimal application (the hello world one from https://wiki.wxpython.org/Getting%20Started#A_First_Application:_.22Hello.2C_World.22 will suffice) cannot be interrupted via SIGINT (Ctrl-C from the parent process) when launched non-interactively in a containerized environment.

Expected vs observed behaviour: When not using a container, the application can be interrupted just fine with CTRL-C (later abbreviated C-c), as shown in this example:

$ cat hello-world.py 
#!/usr/bin/env python
import wx

app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True)     # Show the frame.
app.MainLoop()

$ guix shell python python-wxpython -- python3 hello-world.py
^C
$

When ran inside a Linux container though, it doesn't work anymore:

$ guix shell --container  --network --preserve=XAUTHORITY --expose=$XAUTHORITY --preserve=DISPLAY python python-wxpython -- python3 hello-world.py

(hello-world.py:1): dbind-WARNING **: 17:00:53.777: Couldn't connect to accessibility bus: Failed to connect to socket /run/user/1000/at-spi/bus_1: No such file or directory
^C

It hangs up until the main application window is closed via the window manager.

I'd expect C-c to be able to interrupt the application in both situations, as it works with other applications.

Platform and version information

Tested with Guix at commit deda3cc9057f20b1e3d34d63a64da0bdd6ca1998 which has python-wxpython at version 4.2.0 and python at version 3.10.7 on my Guix System GNU/Linux distribution.

swt2c commented 1 year ago

Can you test whether this happens with a minimal wxWidgets (C++) application (e.g., the minimal sample)?

Apteryks commented 1 year ago

Yes, it happens as well with wxWidgets:

~/src/wxWidgets/mybuild$ guix shell --container  --network --preserve=XAUTHORITY --expose=/gnu --expose=$XAUTHORITY --preserve=DISPLAY -- samples/minimal/minimal

(minimal:1): dbind-WARNING **: 20:42:25.343: Couldn't connect to accessibility bus: Failed to connect to socket /run/user/1000/at-spi/bus_1: No such file or directory
^C

^C^C^C

^C^C

^C^C
[frame still displayed]