aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-05 10:36:40 +0800
committerPo Lu2022-01-05 10:36:40 +0800
commitad63bdf05aa4a0e66139c24fbac8b08b22fc4542 (patch)
tree51d0d653ab8da0fd238a0fb01c8be45eaa5abcf1 /src
parenta7dbbcac571ebf07ec89a09cc8d9bc4fdf2ae063 (diff)
downloademacs-ad63bdf05aa4a0e66139c24fbac8b08b22fc4542.tar.gz
emacs-ad63bdf05aa4a0e66139c24fbac8b08b22fc4542.zip
Fix xwidgets setting their own signal handlers
* src/xgselect.c (release_select_lock): (acquire_select_lock): Fix coding style. (xg_select): Call `catch_child_signal' if xwidgets are enabled. * src/xwidget.c (kill_xwidget): (kill_buffer_xwidgets): Call `catch_child_signal'. (bug#53013)
Diffstat (limited to 'src')
-rw-r--r--src/xgselect.c22
-rw-r--r--src/xwidget.c4
2 files changed, 24 insertions, 2 deletions
diff --git a/src/xgselect.c b/src/xgselect.c
index 8afd3f238f0..674c259db76 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -28,11 +28,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
28#include "lisp.h" 28#include "lisp.h"
29#include "blockinput.h" 29#include "blockinput.h"
30#include "systime.h" 30#include "systime.h"
31#include "process.h"
31 32
32static ptrdiff_t threads_holding_glib_lock; 33static ptrdiff_t threads_holding_glib_lock;
33static GMainContext *glib_main_context; 34static GMainContext *glib_main_context;
34 35
35void release_select_lock (void) 36void
37release_select_lock (void)
36{ 38{
37#if GNUC_PREREQ (4, 7, 0) 39#if GNUC_PREREQ (4, 7, 0)
38 if (__atomic_sub_fetch (&threads_holding_glib_lock, 1, __ATOMIC_ACQ_REL) == 0) 40 if (__atomic_sub_fetch (&threads_holding_glib_lock, 1, __ATOMIC_ACQ_REL) == 0)
@@ -43,7 +45,8 @@ void release_select_lock (void)
43#endif 45#endif
44} 46}
45 47
46static void acquire_select_lock (GMainContext *context) 48static void
49acquire_select_lock (GMainContext *context)
47{ 50{
48#if GNUC_PREREQ (4, 7, 0) 51#if GNUC_PREREQ (4, 7, 0)
49 if (__atomic_fetch_add (&threads_holding_glib_lock, 1, __ATOMIC_ACQ_REL) == 0) 52 if (__atomic_fetch_add (&threads_holding_glib_lock, 1, __ATOMIC_ACQ_REL) == 0)
@@ -181,6 +184,21 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
181#else 184#else
182 need_to_dispatch = true; 185 need_to_dispatch = true;
183#endif 186#endif
187
188 /* xwidgets make heavy use of GLib subprocesses, which add their own
189 SIGCHLD handler at arbitrary locations. That doesn't play well
190 with Emacs's own handler, so once GLib does its thing with its
191 subprocesses we restore our own SIGCHLD handler (which chains the
192 GLib handler) here.
193
194 There is an obvious race condition, but we can't really do
195 anything about that, except hope a SIGCHLD arrives soon to clear
196 up the situation. */
197
198#ifdef HAVE_XWIDGETS
199 catch_child_signal ();
200#endif
201
184 if (need_to_dispatch) 202 if (need_to_dispatch)
185 { 203 {
186 acquire_select_lock (context); 204 acquire_select_lock (context);
diff --git a/src/xwidget.c b/src/xwidget.c
index 24dafa7d3c6..7d6d256a191 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -3610,6 +3610,8 @@ kill_xwidget (struct xwidget *xw)
3610 xw->widget_osr = NULL; 3610 xw->widget_osr = NULL;
3611 xw->widgetwindow_osr = NULL; 3611 xw->widgetwindow_osr = NULL;
3612 xw->find_text = NULL; 3612 xw->find_text = NULL;
3613
3614 catch_child_signal ();
3613#elif defined NS_IMPL_COCOA 3615#elif defined NS_IMPL_COCOA
3614 nsxwidget_kill (xw); 3616 nsxwidget_kill (xw);
3615#endif 3617#endif
@@ -3630,4 +3632,6 @@ kill_buffer_xwidgets (Lisp_Object buffer)
3630 kill_xwidget (xw); 3632 kill_xwidget (xw);
3631 } 3633 }
3632 } 3634 }
3635
3636 catch_child_signal ();
3633} 3637}