[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interrupting computations using signals
From: |
Daniel Mendler |
Subject: |
Re: Interrupting computations using signals |
Date: |
Mon, 24 May 2021 16:08:07 +0200 |
On 5/24/21 2:53 PM, Eli Zaretskii wrote:
>> I've read something in the manual about SIGUSR1/SIGUSR2 but I could not
>> get these handlers to work in an Emacs running in daemon or batch mode.
>
> Show us the code.
I have a file "interrupt.el" containing this code:
~~~
(defun sigusr-handler ()
(interactive)
(message "Caught signal %S" last-input-event))
(define-key special-event-map [sigusr1] 'sigusr-handler)
(define-key special-event-map [sigusr2] 'sigusr-handler)
(condition-case nil
(while t
(with-local-quit
(while t
(sleep-for 0.1)))
(message "QUIT"))
(t (message "OUTER QUIT")))
~~~
1. I start the batch process with "emacs -Q --batch -l interrupt.el" or
"emacs -Q --fg-daemon -l interrupt.el".
2. I send a SIGUSR1 signal to the process. The signal is ignored.
Nothing happens, in particular the handler is not called.
3. I send a SIGUSR2 signal to the process. The process terminates with
the message "Debugger entered--beginning evaluation of function call
form: * (setq quit-flag t)...". I neither see the "QUIT" nor the "OUTER
QUIT" message.
Daniel