Fmake_xwidget: Use about:blank workaround only when needed

* src/process.c (glib_installs_sigchld_handler): New variable.
(init_process_emacs): Set it when GLib overrides Emacs's SIGCHLD
handler.
* src/process.h (glib_installs_sigchld_handler): Declare.
* src/xwidget.c (Fmake_xwidget): Skip the "about:blank"
workaround when glib_installs_sigchld_handler is false.
This commit is contained in:
Dirk-Jan C. Binnema 2026-04-26 15:46:19 +03:00 committed by Sean Whitton
parent f3b17c4969
commit 6df1d33b6c
3 changed files with 28 additions and 6 deletions

View file

@ -7656,6 +7656,12 @@ child_signal_notify (void)
static void dummy_handler (int sig) {} static void dummy_handler (int sig) {}
static signal_handler_t volatile lib_child_handler; 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 /* Handle a SIGCHLD signal by looking for known child processes of
Emacs whose status have changed. For each one found, record its Emacs whose status have changed. For each one found, record its
new status. new status.
@ -8718,6 +8724,7 @@ init_process_emacs (int sockfd)
if (lib_child_handler != dummy_handler) if (lib_child_handler != dummy_handler)
{ {
/* The hacky workaround is needed on this platform. */ /* The hacky workaround is needed on this platform. */
glib_installs_sigchld_handler = true;
signal_handler_t lib_child_handler_glib = lib_child_handler; signal_handler_t lib_child_handler_glib = lib_child_handler;
catch_child_signal (); catch_child_signal ();
eassert (lib_child_handler == dummy_handler); eassert (lib_child_handler == dummy_handler);

View file

@ -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 /* True means don't run process sentinels. This is used
when exiting. */ when exiting. */
extern bool inhibit_sentinels; 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. */ /* Exit statuses for GNU programs that exec other programs. */
enum enum

View file

@ -361,13 +361,26 @@ fails. */)
g_signal_connect (G_OBJECT (ctx), g_signal_connect (G_OBJECT (ctx),
"download-started", "download-started",
G_CALLBACK (webkit_download_cb), xw); 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), webkit_web_view_load_uri() is potentially affected by this
"about:blank"); (through GSubProcess), so as a workaround we load a minimal
/* webkitgtk uses GSubprocess which sets sigaction causing about:blank url and restore the SIGCHLD handler afterward.
Emacs to not catch SIGCHLD with its usual handle setup in
'catch_child_signal'. This resets the SIGCHLD sigaction. */ With PGTK, this workaround has the unfortunate side-effect of
catch_child_signal (); making the first load of an URI not work immediately (it needs
a refresh), so avoid the workaround when we can.
See thread
<https://lists.gnu.org/archive/html/emacs-devel/2026-04/msg00810.html>. */
if (glib_installs_sigchld_handler)
{
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (xw->widget_osr),
"about:blank");
catch_child_signal ();
}
} }
else else
{ {