=== modified file 'doc/emacs/trouble.texi' --- doc/emacs/trouble.texi 2011-01-25 04:08:28 +0000 +++ doc/emacs/trouble.texi 2011-03-28 06:53:07 +0000 @@ -812,6 +812,15 @@ This backtrace is useful for debugging such long loops, so if you can produce it, copy it into the bug report. address@hidden sigusr2-action +If normal quitting does nothing and you are using a system that +supports signals, then as a last resort, you can try sending Emacs the +SIGUSR2 signal. When Emacs receives this signal, it checks whether address@hidden is equal to @code{quit}. If so, Emacs stops +what it's doing, sets @code{debug-on-quit} to @code{t}, and quits just +as if you had typed @kbd{C-g}. This process happens even in places +where quitting is normally not allowed. + @item Check whether any programs you have loaded into the Lisp world, including your @file{.emacs} file, set any variables that may affect the === modified file 'doc/lispref/debugging.texi' --- doc/lispref/debugging.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/debugging.texi 2011-03-28 06:54:07 +0000 @@ -185,6 +185,19 @@ when you quit. @xref{Quitting}. @end defopt address@hidden sigusr2-action +On systems with signal support, this variable determines what happens +when Emacs receives SIGUSR2. When its value is @code{quit}, Emacs +will quit just as if @kbd{C-g} had been pressed, except that Emacs +will first set @code{debug-on-quit} to @code{t} and address@hidden to @code{nil} so that the quit is not ignored. +When @code{sigusr2-action} has any other value, Emacs will handle the +signal as specified in @code{special-event-map} (@pxref{Active +Keymaps}). This feature is useful for terminating infinite loops in +places where quits would normally be ignored, such as in code that +runs during redisplay. address@hidden defopt + @node Function Debugging @subsection Entering the Debugger on a Function Call @cindex function call debugging === modified file 'lisp/cus-start.el' --- lisp/cus-start.el 2011-03-27 10:55:07 +0000 +++ lisp/cus-start.el 2011-03-28 06:04:18 +0000 @@ -259,6 +259,10 @@ (suggest-key-bindings keyboard (choice (const :tag "off" nil) (integer :tag "time" 2) (other :tag "on"))) + (sigusr2-action debug + (choice (const :tag "Handle SIGUSR2 normally") + (const :tag "Quit on SIGUSR2" quit)) + "24.1") ;; This is not good news because it will use the wrong ;; version-specific directories when you upgrade. We need === modified file 'src/keyboard.c' --- src/keyboard.c 2011-03-27 02:27:11 +0000 +++ src/keyboard.c 2011-03-28 06:46:50 +0000 @@ -7168,6 +7168,21 @@ SIGNAL_THREAD_CHECK (sig); +#ifdef SIGUSR2 + if (sig == SIGUSR2) + { + /* We can be called at any time, but because variable assignment + is atomic, any races are harmless. */ + if (Vsigusr2_action == Qquit) + { + debug_on_quit = 1; + Vquit_flag = Qt; + Vinhibit_quit = Qnil; + return; + } + } +#endif /* SIGUSR2 */ + for (p = user_signals; p; p = p->next) if (p->sig == sig) { @@ -11356,6 +11371,10 @@ poll_suppress_count = 1; start_polling (); #endif + +#ifdef SIGUSR2 + Vsigusr2_action = Qquit; +#endif } /* This type's only use is in syms_of_keyboard, to initialize the @@ -12178,6 +12197,19 @@ `deactivate-mark' call uses this to set the window selection. */); Vsaved_region_selection = Qnil; +#ifdef SIGUSR2 + DEFVAR_LISP ("sigusr2-action", + Vsigusr2_action, + doc: /* Controls what Emacs does when it receives a +SIGUSR2. If 'quit, set `inhibit-quit' to nil and `quit-flag' to t, +quitting unconditionally at the next opportunity. Any other value +causes nothing to be done. + +In all cases, Emacs generates a `sigusr2' event as it normally +would. See `special-event-map'. */); + Vsigusr2_action = Qnil; +#endif + /* Create the initial keyboard. */ initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (initial_kboard);