From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Interrupting computations using signals Date: Mon, 24 May 2021 17:37:03 +0300 Message-ID: <838s44dwq8.fsf@gnu.org> References: <83cztge1i6.fsf@gnu.org> <6eff79e8-0317-b169-eb70-ae8ee969222b@daniel-mendler.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17215"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Daniel Mendler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 24 16:48:53 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1llBsy-0004Fu-TV for ged-emacs-devel@m.gmane-mx.org; Mon, 24 May 2021 16:48:52 +0200 Original-Received: from localhost ([::1]:53156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llBsx-0000g7-Rq for ged-emacs-devel@m.gmane-mx.org; Mon, 24 May 2021 10:48:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llBhd-0001gO-Dp for emacs-devel@gnu.org; Mon, 24 May 2021 10:37:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39312) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llBhc-0008AL-Np; Mon, 24 May 2021 10:37:08 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3174 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llBhc-0006qm-7N; Mon, 24 May 2021 10:37:08 -0400 In-Reply-To: <6eff79e8-0317-b169-eb70-ae8ee969222b@daniel-mendler.de> (message from Daniel Mendler on Mon, 24 May 2021 16:08:07 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269761 Archived-At: > Cc: emacs-devel@gnu.org > From: Daniel Mendler > Date: Mon, 24 May 2021 16:08:07 +0200 > > 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. See the documentation of debug-on-event to understand the effect of SIGUSR2. As for the effect of SIGUSR1, I think that at least part of the issue is that you never give Emacs the chance to read the sigusr1 "key". As you see from the example in the ELisp manual that you copied, this feature works by generating an input event, but if Emacs doesn't read input, it will never pay attention. I guess this is where you tell more about your use case, so that we could understand why, for example, what SIGUSR2 does is not what you wanted.