unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: "Ami Fischman" <ami@fischman.org>
Cc: emacs-devel@gnu.org
Subject: Re: poor handling of multiple C-g with multi-tty (apparent hangs)
Date: Mon, 11 Aug 2008 13:40:53 -0400	[thread overview]
Message-ID: <87tzdr4fh6.fsf@stupidchicken.com> (raw)
In-Reply-To: <b5a678470808102314p40edbfa1m9545c1d0d7ffd12c@mail.gmail.com> (Ami Fischman's message of "Sun, 10 Aug 2008 23:14:21 -0700")

"Ami Fischman" <ami@fischman.org> 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
        )
      {




  reply	other threads:[~2008-08-11 17:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-11  6:14 poor handling of multiple C-g with multi-tty (apparent hangs) Ami Fischman
2008-08-11 17:40 ` Chong Yidong [this message]
2008-08-11 18:56   ` Dan Nicolaescu
2008-08-11 22:00     ` Chong Yidong
2008-08-12  4:53     ` Richard M. Stallman
2008-08-11 21:19   ` Ami Fischman
     [not found] ` <48a85bf8.02a6420a.410f.ffffc5a1MFETCHER_ADDED@google.com>
2008-09-15 23:00   ` Ami Fischman
2008-09-16  3:16     ` Eli Zaretskii
2008-09-16  3:33       ` Ami Fischman
2008-09-16 14:00     ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2008-12-20 13:13 Markus Triska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tzdr4fh6.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=ami@fischman.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).