comparison src/emacs.c @ 58986:59945307b86b

* 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.
author Jan Djärv <jan.h.d@swipnet.se>
date Wed, 15 Dec 2004 21:40:41 +0000
parents 4406d551c5c6
children 51027cf26edc
comparison
equal deleted inserted replaced
58985:0395e55b4aa7 58986:59945307b86b
340 /* If non-null, call this function from fatal_error_signal before 340 /* If non-null, call this function from fatal_error_signal before
341 committing suicide. */ 341 committing suicide. */
342 342
343 void (*fatal_error_signal_hook) P_ ((void)); 343 void (*fatal_error_signal_hook) P_ ((void));
344 344
345 #ifdef HAVE_GTK_AND_PTHREAD
346 /* When compiled with GTK and running under Gnome, multiple threads meay be
347 created. Keep track of our main thread to make sure signals are delivered
348 to it (see syssignal.h). */
349
350 pthread_t main_thread;
351 #endif
352
345 353
346 #ifdef SIGUSR1 354 #ifdef SIGUSR1
347 SIGTYPE 355 SIGTYPE
348 handle_USR1_signal (sig) 356 handle_USR1_signal (sig)
349 int sig; 357 int sig;
350 { 358 {
351 struct input_event buf; 359 struct input_event buf;
352 360
361 SIGNAL_THREAD_CHECK (sig);
353 bzero (&buf, sizeof buf); 362 bzero (&buf, sizeof buf);
354 buf.kind = USER_SIGNAL_EVENT; 363 buf.kind = USER_SIGNAL_EVENT;
355 buf.frame_or_window = selected_frame; 364 buf.frame_or_window = selected_frame;
356 365
357 kbd_buffer_store_event (&buf); 366 kbd_buffer_store_event (&buf);
363 handle_USR2_signal (sig) 372 handle_USR2_signal (sig)
364 int sig; 373 int sig;
365 { 374 {
366 struct input_event buf; 375 struct input_event buf;
367 376
377 SIGNAL_THREAD_CHECK (sig);
368 bzero (&buf, sizeof buf); 378 bzero (&buf, sizeof buf);
369 buf.kind = USER_SIGNAL_EVENT; 379 buf.kind = USER_SIGNAL_EVENT;
370 buf.code = 1; 380 buf.code = 1;
371 buf.frame_or_window = selected_frame; 381 buf.frame_or_window = selected_frame;
372 382
377 /* Handle bus errors, invalid instruction, etc. */ 387 /* Handle bus errors, invalid instruction, etc. */
378 SIGTYPE 388 SIGTYPE
379 fatal_error_signal (sig) 389 fatal_error_signal (sig)
380 int sig; 390 int sig;
381 { 391 {
392 SIGNAL_THREAD_CHECK (sig);
382 fatal_error_code = sig; 393 fatal_error_code = sig;
383 signal (sig, SIG_DFL); 394 signal (sig, SIG_DFL);
384 395
385 TOTALLY_UNBLOCK_INPUT; 396 TOTALLY_UNBLOCK_INPUT;
386 397
416 SIGTYPE 427 SIGTYPE
417 memory_warning_signal (sig) 428 memory_warning_signal (sig)
418 int sig; 429 int sig;
419 { 430 {
420 signal (sig, memory_warning_signal); 431 signal (sig, memory_warning_signal);
432 SIGNAL_THREAD_CHECK (sig);
421 433
422 malloc_warning ("Operating system warns that virtual memory is running low.\n"); 434 malloc_warning ("Operating system warns that virtual memory is running low.\n");
423 435
424 /* It might be unsafe to call do_auto_save now. */ 436 /* It might be unsafe to call do_auto_save now. */
425 force_auto_save_soon (); 437 force_auto_save_soon ();
1026 # ifndef SYNC_INPUT 1038 # ifndef SYNC_INPUT
1027 /* Arrange to disable interrupt input inside malloc etc. */ 1039 /* Arrange to disable interrupt input inside malloc etc. */
1028 uninterrupt_malloc (); 1040 uninterrupt_malloc ();
1029 # endif /* not SYNC_INPUT */ 1041 # endif /* not SYNC_INPUT */
1030 #endif /* not SYSTEM_MALLOC */ 1042 #endif /* not SYSTEM_MALLOC */
1043
1044 #ifdef HAVE_GTK_AND_PTHREAD
1045 main_thread = pthread_self ();
1046 #endif /* HAVE_GTK_AND_PTHREAD */
1031 1047
1032 #if defined (MSDOS) || defined (WINDOWSNT) 1048 #if defined (MSDOS) || defined (WINDOWSNT)
1033 /* We do all file input/output as binary files. When we need to translate 1049 /* We do all file input/output as binary files. When we need to translate
1034 newlines, we do that manually. */ 1050 newlines, we do that manually. */
1035 _fmode = O_BINARY; 1051 _fmode = O_BINARY;