diff options
| author | Akira Kyle | 2020-11-14 16:39:41 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-11-14 16:39:41 +0100 |
| commit | e71f5f1fd1fdeda52fda537ed3b45c8fcc435cac (patch) | |
| tree | 199d9d8a42aca79c9c67bee04048cc87d220c11a /src/process.c | |
| parent | 8700319109c06932cd66615c85fc21e386b40df6 (diff) | |
| download | emacs-e71f5f1fd1fdeda52fda537ed3b45c8fcc435cac.tar.gz emacs-e71f5f1fd1fdeda52fda537ed3b45c8fcc435cac.zip | |
Work around glib messing with signal handlers more than it should
* src/process.c (init_process_emacs): force glib's g_unix_signal
handler into lib_child_handler where it should belong.
Copyright-paperwork-exempt: yes
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/process.c b/src/process.c index 50c425077a9..bf64ead24e5 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -8217,13 +8217,29 @@ init_process_emacs (int sockfd) | |||
| 8217 | if (!will_dump_with_unexec_p ()) | 8217 | if (!will_dump_with_unexec_p ()) |
| 8218 | { | 8218 | { |
| 8219 | #if defined HAVE_GLIB && !defined WINDOWSNT | 8219 | #if defined HAVE_GLIB && !defined WINDOWSNT |
| 8220 | /* Tickle glib's child-handling code. Ask glib to wait for Emacs itself; | 8220 | /* Tickle glib's child-handling code. Ask glib to install a |
| 8221 | this should always fail, but is enough to initialize glib's | 8221 | watch source for Emacs itself which will initialize glib's |
| 8222 | private SIGCHLD handler, allowing catch_child_signal to copy | 8222 | private SIGCHLD handler, allowing catch_child_signal to copy |
| 8223 | it into lib_child_handler. */ | 8223 | it into lib_child_handler. |
| 8224 | g_source_unref (g_child_watch_source_new (getpid ())); | 8224 | |
| 8225 | #endif | 8225 | Unfortunatly in glib commit 2e471acf, the behavior changed to |
| 8226 | always install a signal handler when g_child_watch_source_new | ||
| 8227 | is called and not just the first time it's called. Glib also | ||
| 8228 | now resets signal handlers to SIG_DFL when it no longer has a | ||
| 8229 | watcher on that signal. This is a hackey work around to get | ||
| 8230 | glib's g_unix_signal_handler into lib_child_handler. */ | ||
| 8231 | GSource *source = g_child_watch_source_new (getpid ()); | ||
| 8232 | catch_child_signal (); | ||
| 8233 | g_source_unref (source); | ||
| 8234 | |||
| 8235 | eassert (lib_child_handler != dummy_handler); | ||
| 8236 | signal_handler_t lib_child_handler_glib = lib_child_handler; | ||
| 8226 | catch_child_signal (); | 8237 | catch_child_signal (); |
| 8238 | eassert (lib_child_handler == dummy_handler); | ||
| 8239 | lib_child_handler = lib_child_handler_glib; | ||
| 8240 | #else | ||
| 8241 | catch_child_signal (); | ||
| 8242 | #endif | ||
| 8227 | } | 8243 | } |
| 8228 | 8244 | ||
| 8229 | #ifdef HAVE_SETRLIMIT | 8245 | #ifdef HAVE_SETRLIMIT |