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: poor handling of multiple C-g with multi-tty (apparent hangs) Date: Mon, 11 Aug 2008 13:40:53 -0400 Message-ID: <87tzdr4fh6.fsf@stupidchicken.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1218476493 631 80.91.229.12 (11 Aug 2008 17:41:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Aug 2008 17:41:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Ami Fischman" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 11 19:42:24 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 1KSbPF-0005Xk-PO for ged-emacs-devel@m.gmane.org; Mon, 11 Aug 2008 19:42:10 +0200 Original-Received: from localhost ([127.0.0.1]:52340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSbOK-0001fO-3F for ged-emacs-devel@m.gmane.org; Mon, 11 Aug 2008 13:41:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSbNe-0000uJ-90 for emacs-devel@gnu.org; Mon, 11 Aug 2008 13:40:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSbNd-0000t4-IT for emacs-devel@gnu.org; Mon, 11 Aug 2008 13:40:29 -0400 Original-Received: from [199.232.76.173] (port=41345 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSbNd-0000sk-5I for emacs-devel@gnu.org; Mon, 11 Aug 2008 13:40:29 -0400 Original-Received: from cyd.mit.edu ([18.115.2.24]:60080 helo=cyd) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSbNc-0007HN-Ff for emacs-devel@gnu.org; Mon, 11 Aug 2008 13:40:28 -0400 Original-Received: by cyd (Postfix, from userid 1000) id 447F257E1CA; Mon, 11 Aug 2008 13:40:53 -0400 (EDT) In-Reply-To: (Ami Fischman's message of "Sun, 10 Aug 2008 23:14:21 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: 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:102290 Archived-At: "Ami Fischman" writes: > Emacs has code to deal with C-g being entered while a quit is already > in progress, meant to suspend emacs and drop the user to the superior > shell or debugger (see section 59.7 Emergency Escape of the emacs > info). This is done if emacs believes it's a good idea, which > criteria includes "running in tty mode". Unfortunately this was never > updated to work correctly with the multi-tty patch. Thanks for pointing this out. IIUC, the "emergency C-g" behavior is geared towards the traditional setup where there's only one text-only terminal available. There, the emergency C-g is the only way to drop back to the shell if Emacs gets stuck. It's disabled for graphical terminals because there, you can open up a separate terminal to kill/suspend the Emacs process. This implies that we should disable the emergency C-g if Emacs is running on more than one terminal, as in the following patch. *** trunk/src/keyboard.c.~1.969.~ 2008-08-05 17:08:23.000000000 -0400 --- trunk/src/keyboard.c 2008-08-11 13:35:43.000000000 -0400 *************** *** 10953,10958 **** --- 10953,10976 ---- errno = old_errno; } + /* If there is exactly one terminal active, return it. Otherwise, + return NULL. */ + + static struct terminal * + just_one_tty_p () + { + struct terminal *t, *found = NULL; + for (t = terminal_list; t; t = t->next_terminal) + if (TERMINAL_ACTIVE_P (t)) + { + if (found) + return NULL; + else + found = t; + } + return found; + } + /* This routine is called at interrupt level in response to C-g. It is called from the SIGINT handler or kbd_buffer_store_event. *************** *** 10968,10980 **** handle_interrupt () { char c; cancel_echoing (); - /* XXX This code needs to be revised for multi-tty support. */ if (!NILP (Vquit_flag) #ifndef MSDOS ! && get_named_tty ("/dev/tty") #endif ) { --- 10986,10999 ---- handle_interrupt () { char c; + struct terminal *t; cancel_echoing (); if (!NILP (Vquit_flag) #ifndef MSDOS ! && (t = just_one_tty_p (), t) ! && t->type == output_termcap #endif ) {