emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Unconditional quit on SIGUSR2


From: Daniel Colascione
Subject: [PATCH] Unconditional quit on SIGUSR2
Date: Mon, 28 Mar 2011 00:14:22 -0700
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

Sometimes Emacs gets stuck in places where quitting is suppressed,
such as during redisplay.  For most users, the only way to deal with
this situation is to abruptly terminate Emacs.

This patch allows users to recover from this situation by sending Emacs
a SIGUSR2 signal.  When we receive it, we set debug-on-quit to t,
inhibit-quit to nil, and quit-flag to t.  These operations will force
Emacs to stop at the next possible opportunity and display a backtrace.
 From here, users can save their work, and developers can figure out
what caused the hang.

This functionality cannot be achieved by simply modifying
special-event-map: event handled by this keymap are delivered too late
to cancel some loops.  For example, even after (define-key
special-event-map [sigusr2] #'debug), SIGUSR2 will not break out of a
(while t) loop.

Instead, we introduce a new sigusr2-action variable that controls the
operation of the signal handler at a lower level.  If this variable has
value 'quit, then when we receive SIGUSR2, we perform the operations we
described above and eat the signal.  Otherwise, we generate an event and
send it through special-event-map as before.  In order to be maximally
useful to users encountering unexpected infinite loops, we set
sigusr2-action to 'quit by default.

SIGUSR2 is chosen under the assumption that users would use SIGUSR1
instead of SIGUSR2 to implement any custom functionality based on
receiving signals through special-event-map, reducing the likelihood of
breaking existing code.

Attachment: debugsig.patch
Description: Text document

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]