From 333f1b6f78ea3923fd49c8bb7f4d4aef39549591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Wed, 15 Dec 2004 21:40:41 +0000 Subject: * syssignal.h: Declare main_thread. (SIGNAL_THREAD_CHECK): New macro. * keyboard.c (input_available_signal): Move thread checking code to macro SIGNAL_THREAD_CHECK and call that macro. (interrupt_signal): Call SIGNAL_THREAD_CHECK. * alloc.c (uninterrupt_malloc): Move main_thread to emacs.c. * emacs.c: Define main_thread. (main): Initialize main_thread. (handle_USR1_signal, handle_USR2_signal, fatal_error_signal) (memory_warning_signal): Call SIGNAL_THREAD_CHECK. * floatfns.c (float_error): Call SIGNAL_THREAD_CHECK. * dispnew.c (window_change_signal): Call SIGNAL_THREAD_CHECK. * sysdep.c (select_alarm): Call SIGNAL_THREAD_CHECK. * process.c (send_process_trap, sigchld_handler): Call SIGNAL_THREAD_CHECK. * data.c (arith_error): Call SIGNAL_THREAD_CHECK. * atimer.c (alarm_signal_handler): Call SIGNAL_THREAD_CHECK. --- src/emacs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/emacs.c') diff --git a/src/emacs.c b/src/emacs.c index 9fde3a6ed42..791e13dd6d0 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -342,6 +342,14 @@ int fatal_error_in_progress; void (*fatal_error_signal_hook) P_ ((void)); +#ifdef HAVE_GTK_AND_PTHREAD +/* When compiled with GTK and running under Gnome, multiple threads meay be + created. Keep track of our main thread to make sure signals are delivered + to it (see syssignal.h). */ + +pthread_t main_thread; +#endif + #ifdef SIGUSR1 SIGTYPE @@ -350,6 +358,7 @@ handle_USR1_signal (sig) { struct input_event buf; + SIGNAL_THREAD_CHECK (sig); bzero (&buf, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.frame_or_window = selected_frame; @@ -365,6 +374,7 @@ handle_USR2_signal (sig) { struct input_event buf; + SIGNAL_THREAD_CHECK (sig); bzero (&buf, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.code = 1; @@ -379,6 +389,7 @@ SIGTYPE fatal_error_signal (sig) int sig; { + SIGNAL_THREAD_CHECK (sig); fatal_error_code = sig; signal (sig, SIG_DFL); @@ -418,6 +429,7 @@ memory_warning_signal (sig) int sig; { signal (sig, memory_warning_signal); + SIGNAL_THREAD_CHECK (sig); malloc_warning ("Operating system warns that virtual memory is running low.\n"); @@ -1029,6 +1041,10 @@ main (argc, argv # endif /* not SYNC_INPUT */ #endif /* not SYSTEM_MALLOC */ +#ifdef HAVE_GTK_AND_PTHREAD + main_thread = pthread_self (); +#endif /* HAVE_GTK_AND_PTHREAD */ + #if defined (MSDOS) || defined (WINDOWSNT) /* We do all file input/output as binary files. When we need to translate newlines, we do that manually. */ -- cgit v1.2.1