+2013-06-23 Paul Eggert <eggert@cs.ucla.edu>
+
+ Try to avoid malloc SEGVs on Cygwin (Bug#14569).
+ * callproc.c, process.h (block_child_signal, unblock_child_signal):
+ Now extern.
+ * emacs.c (main): Catch SIGCHLD just before initializing gfilenotify.
+ * process.c (catch_child_signal): Block SIGCHLD while futzing with
+ the SIGCHLD handler, since the code is not atomic and (due to glib)
+ signals may be arriving now.
+ * sysdep.c (init_signals): Do not catch child signals here;
+ 'main' now does that later, at a safer time.
+
2013-06-22 Paul Eggert <eggert@cs.ucla.edu>
Clean up SIGCHLD handling a bit (Bug#14569).
\f
/* Block SIGCHLD. */
-static void
+void
block_child_signal (void)
{
sigset_t blocked;
/* Unblock SIGCHLD. */
-static void
+void
unblock_child_signal (void)
{
pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
tzset ();
#endif /* MSDOS */
+ /* Do this after initializing the memory allocator, since it uses
+ glib and glib uses malloc. And do it before anything else that
+ invokes glib, to avoid potential races among glib subthreads in
+ Cygwin glib. gfilenotify invokes glib, so this can't be delayed
+ further. */
+ catch_child_signal ();
+
#ifdef HAVE_GFILENOTIFY
globals_of_gfilenotify ();
#endif
#endif
emacs_sigaction_init (&action, deliver_child_signal);
+ block_child_signal ();
sigaction (SIGCHLD, &action, &old_action);
eassert (! (old_action.sa_flags & SA_SIGINFO));
if (old_action.sa_handler != SIG_DFL && old_action.sa_handler != SIG_IGN
&& old_action.sa_handler != deliver_child_signal)
lib_child_handler = old_action.sa_handler;
+ unblock_child_signal ();
}
\f
/* Defined in callproc.c. */
+extern void block_child_signal (void);
+extern void unblock_child_signal (void);
extern void record_kill_process (struct Lisp_Process *);
/* Defined in process.c. */
sigaction (SIGFPE, &action, 0);
}
- catch_child_signal ();
-
#ifdef SIGUSR1
add_user_signal (SIGUSR1, "sigusr1");
#endif