{
/* Must preserve main program's value of errno. */
int old_errno = errno;
+ struct display *display;
#if defined (USG) && !defined (POSIX_SIGNALS)
/* USG systems forget handlers when they are used;
signal (SIGQUIT, interrupt_signal);
#endif /* USG */
- if (! tty_list)
+ /* See if we have a display on our controlling terminal. */
+ display = get_named_tty_display (NULL);
+ if (!display)
{
- /* If there are no tty frames, exit Emacs.
-
- Emacs should exit on SIGINT if and only if there are no
- frames on its controlling tty and the signal came from there.
- We can check for the first condition, but (alas) not for the
- second. The best we can do is that we only exit if we are
- sure that the SIGINT was from the controlling tty, i.e., if
- there are no termcap frames.
- */
+ /* If there are no frames there, let's pretend that we are a
+ well-behaving UN*X program and quit. */
Fkill_emacs (Qnil);
-
- errno = old_errno;
- return;
}
+ else
+ {
+ /* Otherwise, the SIGINT was probably generated by C-g. */
+
+ /* Set internal_last_event_frame to the top frame of the
+ controlling tty, if we have a frame there. We disable the
+ interrupt key on secondary ttys, so the SIGINT must have come
+ from the controlling tty. */
+ internal_last_event_frame = display->display_info.tty->top_frame;
+
+ handle_interrupt ();
- handle_interrupt ();
+ }
errno = old_errno;
}
}
if (waiting_for_input && !echoing)
- quit_throw_to_read_char ();
+ quit_throw_to_read_char ();
}
/* Handle a C-g by making read_char return C-g. */
only if the current session was a tty session. Now an Emacs
session may have multiple display types, so we always handle
SIGINT. There is special code in interrupt_signal to exit
- Emacs on SIGINT when there are no termcap frames. */
+ Emacs on SIGINT when there are no termcap frames on the
+ controlling terminal. */
signal (SIGINT, interrupt_signal);
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
/* For systems with SysV TERMIO, C-g is set up for both SIGINT and