From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: 23.0.60; read-char unexpectedly halts execution of script Date: Mon, 06 Oct 2008 15:35:28 -0400 Message-ID: <87iqs5wm7z.fsf@cyd.mit.edu> References: <87hc7pr16r.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1223321653 17671 80.91.229.12 (6 Oct 2008 19:34:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2008 19:34:13 +0000 (UTC) Cc: 1082@emacsbugs.donarmstrong.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 06 21:35:11 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KmvrI-0000gq-9q for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2008 21:35:08 +0200 Original-Received: from localhost ([127.0.0.1]:34294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KmvqE-00010E-RK for ged-emacs-devel@m.gmane.org; Mon, 06 Oct 2008 15:34:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KmvqA-0000y5-MV for emacs-devel@gnu.org; Mon, 06 Oct 2008 15:33:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kmvq8-0000xD-Uy for emacs-devel@gnu.org; Mon, 06 Oct 2008 15:33:58 -0400 Original-Received: from [199.232.76.173] (port=33177 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kmvq8-0000xA-P4 for emacs-devel@gnu.org; Mon, 06 Oct 2008 15:33:56 -0400 Original-Received: from cyd.mit.edu ([18.115.2.24]:44238) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kmvq8-0005xp-DQ for emacs-devel@gnu.org; Mon, 06 Oct 2008 15:33:56 -0400 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 3D5CC57E0B6; Mon, 6 Oct 2008 15:35:28 -0400 (EDT) In-Reply-To: <87hc7pr16r.fsf@cyd.mit.edu> (Chong Yidong's message of "Mon, 06 Oct 2008 15:08:44 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104385 Archived-At: Chong Yidong writes: >> Let filter.el consist of the forms: >> >> (defun bc-filter (proc string) >> (message "%s" string)) >> >> (message "starting") >> (setq bc (start-process "bc" nil "/usr/bin/bc")) >> (set-process-filter bc 'bc-filter) >> >> (while t >> (let ((char (read-char nil nil 0.1))) >> (message "char: %s" char))) >> >> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now: >> >> mt-computer:~ mt$ emacs --script filter.el >> starting >> mt-computer:~ mt$ >> >> I expect non-termination in this case > > This broke when SYNC_INPUT became the default. To pin it down further, this breakage seems to be due to not using SA_RESTART in the signal handler. If we set SA_RESTARTi in sysdep.c, the problem disappears. Stefan, could you comment? signal_handler_t sys_signal (int signal_number, signal_handler_t action) { struct sigaction new_action, old_action; sigemptyset (&new_action.sa_mask); new_action.sa_handler = action; #if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) && !defined(SYNC_INPUT) /* Emacs mostly works better with restartable system services. If this flag exists, we probably want to turn it on here. However, on some systems this resets the timeout of `select' which means that `select' never finishes if it keeps getting signals. BROKEN_SA_RESTART is defined on those systems. */ /* It's not clear why the comment above says "mostly works better". --Stef When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll for pending input so we need long-running syscalls to be interrupted after a signal that sets the interrupt_input_pending flag. */ new_action.sa_flags = SA_RESTART; #else new_action.sa_flags = 0; #endif sigaction (signal_number, &new_action, &old_action); return (old_action.sa_handler); }