diff --git a/src/process.c b/src/process.c index d46be48821f..3a14f60b3c2 100644 --- a/src/process.c +++ b/src/process.c @@ -7656,6 +7656,12 @@ child_signal_notify (void) static void dummy_handler (int sig) {} static signal_handler_t volatile lib_child_handler; +/* True if Glib installs its own SIGCHLD handler that Emacs must work + around. Determined once in init_process_emacs; consulted elsewhere + (e.g. xwidget.c) to decide whether the about:blank load workaround + is needed. */ +bool glib_installs_sigchld_handler; + /* Handle a SIGCHLD signal by looking for known child processes of Emacs whose status have changed. For each one found, record its new status. @@ -8718,6 +8724,7 @@ init_process_emacs (int sockfd) if (lib_child_handler != dummy_handler) { /* The hacky workaround is needed on this platform. */ + glib_installs_sigchld_handler = true; signal_handler_t lib_child_handler_glib = lib_child_handler; catch_child_signal (); eassert (lib_child_handler == dummy_handler); diff --git a/src/process.h b/src/process.h index 1c9b04aa06e..c43f2fe1ea9 100644 --- a/src/process.h +++ b/src/process.h @@ -263,6 +263,8 @@ pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val) /* True means don't run process sentinels. This is used when exiting. */ extern bool inhibit_sentinels; +/* True means that Glib clobbers Emacs SIGCHLD handler. */ +extern bool glib_installs_sigchld_handler; /* Exit statuses for GNU programs that exec other programs. */ enum diff --git a/src/xwidget.c b/src/xwidget.c index 0b890375c30..e2ab7499927 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -361,13 +361,26 @@ fails. */) g_signal_connect (G_OBJECT (ctx), "download-started", G_CALLBACK (webkit_download_cb), xw); + /* In process.c:init_process_emacs(), we determine whether GLib + overrides Emacs' SIGCHLD handler (based on Glib version + and kernel; see process.c for details). - webkit_web_view_load_uri (WEBKIT_WEB_VIEW (xw->widget_osr), - "about:blank"); - /* webkitgtk uses GSubprocess which sets sigaction causing - Emacs to not catch SIGCHLD with its usual handle setup in - 'catch_child_signal'. This resets the SIGCHLD sigaction. */ - catch_child_signal (); + webkit_web_view_load_uri() is potentially affected by this + (through GSubProcess), so as a workaround we load a minimal + about:blank url and restore the SIGCHLD handler afterward. + + With PGTK, this workaround has the unfortunate side-effect of + making the first load of an URI not work immediately (it needs + a refresh), so avoid the workaround when we can. + + See thread + . */ + if (glib_installs_sigchld_handler) + { + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (xw->widget_osr), + "about:blank"); + catch_child_signal (); + } } else {