aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorStefan Kangas2025-02-01 04:56:52 +0100
committerStefan Kangas2025-02-01 04:56:52 +0100
commitbf97946d7dc460b7d3c3ce03193041b891b51faf (patch)
treec799f87903ca3dcba8b804bd185b519aacc0a636 /src/process.c
parenta4a0957b6b3b1db858524ac6d4dc3d951f65960b (diff)
parentaa07e94439c663f768c32a689d14506d25a7a5bc (diff)
downloademacs-bf97946d7dc460b7d3c3ce03193041b891b51faf.tar.gz
emacs-bf97946d7dc460b7d3c3ce03193041b891b51faf.zip
Merge branch 'scratch/no-purespace' into 'master'
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/src/process.c b/src/process.c
index 275e86f31d0..807f06f990b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -8640,50 +8640,39 @@ init_process_emacs (int sockfd)
8640 8640
8641 inhibit_sentinels = 0; 8641 inhibit_sentinels = 0;
8642 8642
8643#ifdef HAVE_UNEXEC 8643#if defined HAVE_GLIB && !defined WINDOWSNT
8644 /* Clear child_signal_read_fd and child_signal_write_fd after dumping, 8644 /* Tickle Glib's child-handling code. Ask Glib to install a
8645 lest wait_reading_process_output should select on nonexistent file 8645 watch source for Emacs itself which will initialize glib's
8646 descriptors which existed in the build process. */ 8646 private SIGCHLD handler, allowing catch_child_signal to copy
8647 child_signal_read_fd = -1; 8647 it into lib_child_handler. This is a hacky workaround to get
8648 child_signal_write_fd = -1; 8648 glib's g_unix_signal_handler into lib_child_handler.
8649#endif /* HAVE_UNEXEC */ 8649
8650 In Glib 2.37.5 (2013), commit 2e471acf changed Glib to
8651 always install a signal handler when g_child_watch_source_new
8652 is called and not just the first time it's called, and to
8653 reset signal handlers to SIG_DFL when it no longer has a
8654 watcher on that signal. Arrange for Emacs's signal handler
8655 to be reinstalled even if this happens.
8656
8657 In Glib 2.73.2 (2022), commit f615eef4 changed Glib again,
8658 to not install a signal handler if the system supports
8659 pidfd_open and waitid (as in Linux kernel 5.3+). The hacky
8660 workaround is not needed in this case. */
8661 GSource *source = g_child_watch_source_new (getpid ());
8662 catch_child_signal ();
8663 g_source_unref (source);
8650 8664
8651 if (!will_dump_with_unexec_p ()) 8665 if (lib_child_handler != dummy_handler)
8652 { 8666 {
8653#if defined HAVE_GLIB && !defined WINDOWSNT 8667 /* The hacky workaround is needed on this platform. */
8654 /* Tickle Glib's child-handling code. Ask Glib to install a 8668 signal_handler_t lib_child_handler_glib = lib_child_handler;
8655 watch source for Emacs itself which will initialize glib's
8656 private SIGCHLD handler, allowing catch_child_signal to copy
8657 it into lib_child_handler. This is a hacky workaround to get
8658 glib's g_unix_signal_handler into lib_child_handler.
8659
8660 In Glib 2.37.5 (2013), commit 2e471acf changed Glib to
8661 always install a signal handler when g_child_watch_source_new
8662 is called and not just the first time it's called, and to
8663 reset signal handlers to SIG_DFL when it no longer has a
8664 watcher on that signal. Arrange for Emacs's signal handler
8665 to be reinstalled even if this happens.
8666
8667 In Glib 2.73.2 (2022), commit f615eef4 changed Glib again,
8668 to not install a signal handler if the system supports
8669 pidfd_open and waitid (as in Linux kernel 5.3+). The hacky
8670 workaround is not needed in this case. */
8671 GSource *source = g_child_watch_source_new (getpid ());
8672 catch_child_signal (); 8669 catch_child_signal ();
8673 g_source_unref (source); 8670 eassert (lib_child_handler == dummy_handler);
8674 8671 lib_child_handler = lib_child_handler_glib;
8675 if (lib_child_handler != dummy_handler) 8672 }
8676 {
8677 /* The hacky workaround is needed on this platform. */
8678 signal_handler_t lib_child_handler_glib = lib_child_handler;
8679 catch_child_signal ();
8680 eassert (lib_child_handler == dummy_handler);
8681 lib_child_handler = lib_child_handler_glib;
8682 }
8683#else 8673#else
8684 catch_child_signal (); 8674 catch_child_signal ();
8685#endif 8675#endif
8686 }
8687 8676
8688#ifdef HAVE_SETRLIMIT 8677#ifdef HAVE_SETRLIMIT
8689 /* Don't allocate more than FD_SETSIZE file descriptors for Emacs itself. */ 8678 /* Don't allocate more than FD_SETSIZE file descriptors for Emacs itself. */
@@ -9018,7 +9007,7 @@ sentinel or a process filter function has an error. */);
9018 const struct socket_options *sopt; 9007 const struct socket_options *sopt;
9019 9008
9020#define ADD_SUBFEATURE(key, val) \ 9009#define ADD_SUBFEATURE(key, val) \
9021 subfeatures = pure_cons (pure_cons (key, pure_cons (val, Qnil)), subfeatures) 9010 subfeatures = Fcons (Fcons (key, Fcons (val, Qnil)), subfeatures)
9022 9011
9023 ADD_SUBFEATURE (QCnowait, Qt); 9012 ADD_SUBFEATURE (QCnowait, Qt);
9024#ifdef DATAGRAM_SOCKETS 9013#ifdef DATAGRAM_SOCKETS
@@ -9040,7 +9029,7 @@ sentinel or a process filter function has an error. */);
9040 ADD_SUBFEATURE (QCserver, Qt); 9029 ADD_SUBFEATURE (QCserver, Qt);
9041 9030
9042 for (sopt = socket_options; sopt->name; sopt++) 9031 for (sopt = socket_options; sopt->name; sopt++)
9043 subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); 9032 subfeatures = Fcons (intern_c_string (sopt->name), subfeatures);
9044 9033
9045 Fprovide (intern_c_string ("make-network-process"), subfeatures); 9034 Fprovide (intern_c_string ("make-network-process"), subfeatures);
9046 } 9035 }