From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: read-event in batch mode Date: Fri, 31 Jan 2014 13:48:12 +0200 Message-ID: <831tzo74oz.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1391168901 29905 80.91.229.3 (31 Jan 2014 11:48:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Jan 2014 11:48:21 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 31 12:48:28 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W9CaB-00038z-AN for ged-emacs-devel@m.gmane.org; Fri, 31 Jan 2014 12:48:27 +0100 Original-Received: from localhost ([::1]:55075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9CaA-0002o6-UE for ged-emacs-devel@m.gmane.org; Fri, 31 Jan 2014 06:48:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9Ca1-0002k4-K2 for emacs-devel@gnu.org; Fri, 31 Jan 2014 06:48:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9CZu-000231-B9 for emacs-devel@gnu.org; Fri, 31 Jan 2014 06:48:17 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:48387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9CZu-000227-3Q for emacs-devel@gnu.org; Fri, 31 Jan 2014 06:48:10 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0N0900400K5FM100@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Fri, 31 Jan 2014 13:48:08 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N09004SNKS8LV20@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Fri, 31 Jan 2014 13:48:08 +0200 (IST) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.175 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169268 Archived-At: Currently, read-event waits forever when called in batch mode. This is because of the following fragment from kbd_buffer_get_event: #ifndef HAVE_DBUS /* We want to read D-Bus events in batch mode. */ if (noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ || (IS_DAEMON && daemon_pipe[1] >= 0)) { int c = getchar (); XSETINT (obj, c); *kbp = current_kboard; return obj; } #endif /* ! HAVE_DBUS */ The call to getchar will wait indefinitely, until something is typed on the keyboard. Worse, if Emacs is built with D-Bus, this fragment is bypassed (including if Emacs is run in daemon mode!), and then read-event does honor the timeout. The net effect is that writing code that waits for events and works on all platforms is tricky at best. This was discovered while debugging the problems of file-notify-tests.el, see bug #16519 for more details and context. Does any port for a supported platform need this fragment, or can we safely delete it? What about the daemon -- does it need this "when detaching from the terminal", and if so, why? In any case, I think we need to document this deviant behavior, at least for now, because there's no hint of it anywhere in the docs. Of course, sit-for is also affected by that. Comments?