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: Re: Signals and input Date: Sat, 29 Sep 2012 16:49:56 +0200 Message-ID: <837grcg9yj.fsf@gnu.org> References: <83lifvgvh8.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1348930223 9274 80.91.229.3 (29 Sep 2012 14:50:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Sep 2012 14:50:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 29 16:50:29 2012 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 1THyN3-0003Pa-8f for ged-emacs-devel@m.gmane.org; Sat, 29 Sep 2012 16:50:21 +0200 Original-Received: from localhost ([::1]:45252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THyMx-0006rl-VH for ged-emacs-devel@m.gmane.org; Sat, 29 Sep 2012 10:50:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THyMu-0006rV-MM for emacs-devel@gnu.org; Sat, 29 Sep 2012 10:50:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THyMt-0007DE-GM for emacs-devel@gnu.org; Sat, 29 Sep 2012 10:50:12 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:35617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THyMt-0007Bc-8T for emacs-devel@gnu.org; Sat, 29 Sep 2012 10:50:11 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MB400J0092JDJ00@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Sat, 29 Sep 2012 16:49:54 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MB400JZQ9765270@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Sat, 29 Sep 2012 16:49:54 +0200 (IST) In-reply-to: <83lifvgvh8.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) 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:153707 Archived-At: > Date: Thu, 27 Sep 2012 20:40:35 +0200 > From: Eli Zaretskii > > Given this, there's something I don't understand: why do we force > POLL_FOR_INPUT in an Emacs built for a window-system? We have this in > keyboard.c: > > /* If we support a window system, turn on the code to poll periodically > to detect C-g. It isn't actually used when doing interrupt input. */ > #ifdef HAVE_WINDOW_SYSTEM > #define POLL_FOR_INPUT > #endif > > If keyboard input and X events produce SIGIO, then why do we need to > set up a timer that delivers SIGALRM every second of idle time for the > purposes of polling input? Aren't those SIGALRMs gratuitous, > conducive to race conditions, etc. etc.? > > What's more, HAVE_WINDOW_SYSTEM is a compile-time condition. An Emacs > built with it defined will turn on polling even in a purely TTY > session, which doesn't seem to be needed at all (I think). > > Can someone please help me see what am I missing? TIA. Answering my own question here: the missing link is the variable interrupt_input. It is set to 1 in init_keyboard if INTERRUPT_INPUT is defined, and when non-zero, it effectively disables polling, e.g. start_polling does nothing when that variable is non-zero. If no one more knowledgeable beats me to it, I'll look into describing this in the commentary near the beginning of keyboard.c. I think we should have there at least a high-level description of how Emacs does input, similarly to what xdisp.c says about the display engine.