GNU Emacs Manual. Node: Emergency Escape

PREVAfter a Crash UPLossage NEXTTotal Frustration

28.9.8: Emergency Escape

Because at times there have been bugs causing Emacs to loop without checking quit-flag, a special feature causes Emacs to be suspended immediately if you type a second C-g while the flag is already set, so you can always get out of GNU Emacs. Normally Emacs recognizes and clears quit-flag (and quits!) quickly enough to prevent this from happening. (On MS-DOS and compatible systems, type C-BREAK twice.)

When you resume Emacs after a suspension caused by multiple C-g, it asks two questions before going back to what it had been doing:

Auto-save? (y or n)
Abort (and dump core)? (y or n)

Answer each one with y or n followed by RET.

Saying y to `Auto-save?' causes immediate auto-saving of all modified buffers in which auto-saving is enabled.

Saying y to `Abort (and dump core)?' causes an illegal instruction to be executed, dumping core. This is to enable a wizard to figure out why Emacs was failing to quit in the first place. Execution does not continue after a core dump. If you answer n, execution does continue. With luck, GNU Emacs will ultimately check quit-flag and quit normally. If not, and you type another C-g, it is suspended again.

If Emacs is not really hung, just slow, you may invoke the double C-g feature without really meaning to. Then just resume and answer n to both questions, and you will arrive at your former state. Presumably the quit you requested will happen soon.

The double-C-g feature is turned off when Emacs is running under the X Window System, since you can use the window manager to kill Emacs or to create another window and run another program.

On MS-DOS and compatible systems, the emergency escape feature is sometimes unavailable, even if you press C-BREAK twice, when some system call (MS-DOS or BIOS) hangs, or when Emacs is stuck in a very tight endless loop (in C code, not in Lisp code).

PREVAfter a Crash UPLossage NEXTTotal Frustration