From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#1082: 23.0.60; read-char unexpectedly halts execution of script Date: Mon, 06 Oct 2008 15:35:28 -0400 Message-ID: <87iqs5wm7z.fsf__1328.96260261095$1223322708$gmane$org@cyd.mit.edu> References: <87hc7pr16r.fsf@cyd.mit.edu> Reply-To: Chong Yidong , 1082@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1223322643 21192 80.91.229.12 (6 Oct 2008 19:50:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Oct 2008 19:50:43 +0000 (UTC) Cc: 1082@emacsbugs.donarmstrong.com To: emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 06 21:51:38 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kmw70-0006rY-Ou for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Oct 2008 21:51:23 +0200 Original-Received: from localhost ([127.0.0.1]:35789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kmw5x-0005zi-8R for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Oct 2008 15:50:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kmw5j-0005qo-8V for bug-gnu-emacs@gnu.org; Mon, 06 Oct 2008 15:50:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kmw5g-0005pi-Tl for bug-gnu-emacs@gnu.org; Mon, 06 Oct 2008 15:50:02 -0400 Original-Received: from [199.232.76.173] (port=50035 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kmw5g-0005pW-BZ for bug-gnu-emacs@gnu.org; Mon, 06 Oct 2008 15:50:00 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:40348) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kmw5f-0002EV-LH for bug-gnu-emacs@gnu.org; Mon, 06 Oct 2008 15:50:00 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m96JnvKx029390; Mon, 6 Oct 2008 12:49:57 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m96Je4Jw027150; Mon, 6 Oct 2008 12:40:04 -0700 X-Loop: don@donarmstrong.com Resent-From: Chong Yidong Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Mon, 06 Oct 2008 19:40:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1082 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1082-submit@emacsbugs.donarmstrong.com id=B1082.122332163925814 (code B ref 1082); Mon, 06 Oct 2008 19:40:04 +0000 Original-Received: (at 1082) by emacsbugs.donarmstrong.com; 6 Oct 2008 19:33:59 +0000 Original-Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m96JXuh2025808 for <1082@emacsbugs.donarmstrong.com>; Mon, 6 Oct 2008 12:33:57 -0700 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) Resent-Date: Mon, 06 Oct 2008 15:50:02 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:21187 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); }