aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2011-12-04 10:26:30 +0100
committerAndreas Schwab2011-12-04 10:26:30 +0100
commit6c07aac2835c5ec4462fedb267f1bba5bb3cadc5 (patch)
tree4b8a0f5a7728830f323014ea541d1ec3c41c678b /src
parentc80e3b4aed2e70eb6d8445d786c0df770094e9e1 (diff)
downloademacs-6c07aac2835c5ec4462fedb267f1bba5bb3cadc5.tar.gz
emacs-6c07aac2835c5ec4462fedb267f1bba5bb3cadc5.zip
Don't call Lisp in signal handler
* emacs.c (Qkill_emacs): Define. (syms_of_emacs): Initialize it. * keyboard.c (interrupt_signal): Don't call Fkill_emacs here, set Qquit_flag to `kill-emacs' instead. (quit_throw_to_read_char): Add parameter `from_signal'. All callers changed. Call Fkill_emacs if requested and safe. * lisp.h (QUIT): Call Fkill_emacs if requested.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/emacs.c3
-rw-r--r--src/keyboard.c29
-rw-r--r--src/lisp.h8
4 files changed, 36 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6a13bd87264..a1d5cc9d5bd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12011-12-04 Andreas Schwab <schwab@linux-m68k.org>
2
3 * emacs.c (Qkill_emacs): Define.
4 (syms_of_emacs): Initialize it.
5 * keyboard.c (interrupt_signal): Don't call Fkill_emacs here, set
6 Qquit_flag to `kill-emacs' instead.
7 (quit_throw_to_read_char): Add parameter `from_signal'. All
8 callers changed. Call Fkill_emacs if requested and safe.
9 * lisp.h (QUIT): Call Fkill_emacs if requested.
10
12011-12-03 Jan Djärv <jan.h.d@swipnet.se> 112011-12-03 Jan Djärv <jan.h.d@swipnet.se>
2 12
3 * widget.c (update_wm_hints): Return if wmshell is null. 13 * widget.c (update_wm_hints): Return if wmshell is null.
diff --git a/src/emacs.c b/src/emacs.c
index 529fa35a5bd..6bfc0dc60d0 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -154,6 +154,8 @@ Lisp_Object Qfile_name_handler_alist;
154 154
155Lisp_Object Qrisky_local_variable; 155Lisp_Object Qrisky_local_variable;
156 156
157Lisp_Object Qkill_emacs;
158
157/* If non-zero, Emacs should not attempt to use a window-specific code, 159/* If non-zero, Emacs should not attempt to use a window-specific code,
158 but instead should use the virtual terminal under which it was started. */ 160 but instead should use the virtual terminal under which it was started. */
159int inhibit_window_system; 161int inhibit_window_system;
@@ -2394,6 +2396,7 @@ syms_of_emacs (void)
2394{ 2396{
2395 DEFSYM (Qfile_name_handler_alist, "file-name-handler-alist"); 2397 DEFSYM (Qfile_name_handler_alist, "file-name-handler-alist");
2396 DEFSYM (Qrisky_local_variable, "risky-local-variable"); 2398 DEFSYM (Qrisky_local_variable, "risky-local-variable");
2399 DEFSYM (Qkill_emacs, "kill-emacs");
2397 2400
2398#ifndef CANNOT_DUMP 2401#ifndef CANNOT_DUMP
2399 defsubr (&Sdump_emacs); 2402 defsubr (&Sdump_emacs);
diff --git a/src/keyboard.c b/src/keyboard.c
index 7da0348cb25..a114e495cf7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -464,7 +464,7 @@ static void input_available_signal (int signo);
464static Lisp_Object (Fcommand_execute) (Lisp_Object, Lisp_Object, Lisp_Object, 464static Lisp_Object (Fcommand_execute) (Lisp_Object, Lisp_Object, Lisp_Object,
465 Lisp_Object); 465 Lisp_Object);
466static void handle_interrupt (void); 466static void handle_interrupt (void);
467static void quit_throw_to_read_char (void) NO_RETURN; 467static void quit_throw_to_read_char (int) NO_RETURN;
468static void timer_start_idle (void); 468static void timer_start_idle (void);
469static void timer_stop_idle (void); 469static void timer_stop_idle (void);
470static void timer_resume_idle (void); 470static void timer_resume_idle (void);
@@ -653,7 +653,7 @@ echo_now (void)
653 echo_kboard = current_kboard; 653 echo_kboard = current_kboard;
654 654
655 if (waiting_for_input && !NILP (Vquit_flag)) 655 if (waiting_for_input && !NILP (Vquit_flag))
656 quit_throw_to_read_char (); 656 quit_throw_to_read_char (0);
657} 657}
658 658
659/* Turn off echoing, for the start of a new command. */ 659/* Turn off echoing, for the start of a new command. */
@@ -3817,7 +3817,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3817 /* If the quit flag is set, then read_char will return 3817 /* If the quit flag is set, then read_char will return
3818 quit_char, so that counts as "available input." */ 3818 quit_char, so that counts as "available input." */
3819 if (!NILP (Vquit_flag)) 3819 if (!NILP (Vquit_flag))
3820 quit_throw_to_read_char (); 3820 quit_throw_to_read_char (0);
3821 3821
3822 /* One way or another, wait until input is available; then, if 3822 /* One way or another, wait until input is available; then, if
3823 interrupt handlers have not read it, read it now. */ 3823 interrupt handlers have not read it, read it now. */
@@ -10824,7 +10824,7 @@ set_waiting_for_input (struct timeval *time_to_clear)
10824 /* If handle_interrupt was called before and buffered a C-g, 10824 /* If handle_interrupt was called before and buffered a C-g,
10825 make it run again now, to avoid timing error. */ 10825 make it run again now, to avoid timing error. */
10826 if (!NILP (Vquit_flag)) 10826 if (!NILP (Vquit_flag))
10827 quit_throw_to_read_char (); 10827 quit_throw_to_read_char (0);
10828} 10828}
10829 10829
10830void 10830void
@@ -10839,7 +10839,7 @@ clear_waiting_for_input (void)
10839 10839
10840 If we have a frame on the controlling tty, we assume that the 10840 If we have a frame on the controlling tty, we assume that the
10841 SIGINT was generated by C-g, so we call handle_interrupt. 10841 SIGINT was generated by C-g, so we call handle_interrupt.
10842 Otherwise, the handler kills Emacs. */ 10842 Otherwise, tell QUIT to kill Emacs. */
10843 10843
10844static void 10844static void
10845interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10845interrupt_signal (int signalnum) /* If we don't have an argument, some */
@@ -10856,12 +10856,10 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10856 if (!terminal) 10856 if (!terminal)
10857 { 10857 {
10858 /* If there are no frames there, let's pretend that we are a 10858 /* If there are no frames there, let's pretend that we are a
10859 well-behaving UN*X program and quit. We cannot do that while 10859 well-behaving UN*X program and quit. We must not call Lisp
10860 GC is in progress, though. */ 10860 in a signal handler, so tell QUIT to exit when it is
10861 if (!gc_in_progress && !waiting_for_input) 10861 safe. */
10862 Fkill_emacs (Qnil); 10862 Vquit_flag = Qkill_emacs;
10863 else
10864 Vquit_flag = Qt;
10865 } 10863 }
10866 else 10864 else
10867 { 10865 {
@@ -11010,15 +11008,20 @@ handle_interrupt (void)
11010 separate event loop thread like W32. */ 11008 separate event loop thread like W32. */
11011#ifndef HAVE_NS 11009#ifndef HAVE_NS
11012 if (waiting_for_input && !echoing) 11010 if (waiting_for_input && !echoing)
11013 quit_throw_to_read_char (); 11011 quit_throw_to_read_char (1);
11014#endif 11012#endif
11015} 11013}
11016 11014
11017/* Handle a C-g by making read_char return C-g. */ 11015/* Handle a C-g by making read_char return C-g. */
11018 11016
11019static void 11017static void
11020quit_throw_to_read_char (void) 11018quit_throw_to_read_char (int from_signal)
11021{ 11019{
11020 /* When not called from a signal handler it is safe to call
11021 Lisp. */
11022 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
11023 Fkill_emacs (Qnil);
11024
11022 sigfree (); 11025 sigfree ();
11023 /* Prevent another signal from doing this before we finish. */ 11026 /* Prevent another signal from doing this before we finish. */
11024 clear_waiting_for_input (); 11027 clear_waiting_for_input ();
diff --git a/src/lisp.h b/src/lisp.h
index e645fbd65a5..969923b7cfb 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2128,7 +2128,10 @@ extern char *stack_bottom;
2128 Exception: if you set immediate_quit to nonzero, 2128 Exception: if you set immediate_quit to nonzero,
2129 then the handler that responds to the C-g does the quit itself. 2129 then the handler that responds to the C-g does the quit itself.
2130 This is a good thing to do around a loop that has no side effects 2130 This is a good thing to do around a loop that has no side effects
2131 and (in particular) cannot call arbitrary Lisp code. */ 2131 and (in particular) cannot call arbitrary Lisp code.
2132
2133 If quit-flag is set to `kill-emacs' the SIGINT handler has received
2134 a request to exit Emacs when it is safe to do. */
2132 2135
2133#ifdef SYNC_INPUT 2136#ifdef SYNC_INPUT
2134extern void process_pending_signals (void); 2137extern void process_pending_signals (void);
@@ -2146,6 +2149,8 @@ extern int pending_signals;
2146 { \ 2149 { \
2147 Lisp_Object flag = Vquit_flag; \ 2150 Lisp_Object flag = Vquit_flag; \
2148 Vquit_flag = Qnil; \ 2151 Vquit_flag = Qnil; \
2152 if (EQ (flag, Qkill_emacs)) \
2153 Fkill_emacs (Qnil); \
2149 if (EQ (Vthrow_on_input, flag)) \ 2154 if (EQ (Vthrow_on_input, flag)) \
2150 Fthrow (Vthrow_on_input, Qt); \ 2155 Fthrow (Vthrow_on_input, Qt); \
2151 Fsignal (Qquit, Qnil); \ 2156 Fsignal (Qquit, Qnil); \
@@ -3291,6 +3296,7 @@ extern Lisp_Object Qfile_name_handler_alist;
3291#ifdef FLOAT_CATCH_SIGILL 3296#ifdef FLOAT_CATCH_SIGILL
3292extern void fatal_error_signal (int); 3297extern void fatal_error_signal (int);
3293#endif 3298#endif
3299extern Lisp_Object Qkill_emacs;
3294EXFUN (Fkill_emacs, 1) NO_RETURN; 3300EXFUN (Fkill_emacs, 1) NO_RETURN;
3295#if HAVE_SETLOCALE 3301#if HAVE_SETLOCALE
3296void fixup_locale (void); 3302void fixup_locale (void);