/* Functions related to terminal devices.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
}
-/* Remove a terminal from the terminal list and free its memory. */
+/* Low-level function to close all frames on a terminal, remove it
+ from the terminal list and free its memory. */
void
delete_terminal (struct terminal *terminal)
{
struct terminal **tp;
Lisp_Object tail, frame;
-
- /* Check for and close live frames that are still on this
- terminal. */
+
+ /* Protect against recursive calls. Fdelete_frame calls the
+ delete_terminal_hook when we delete our last frame. */
+ if (terminal->deleted)
+ return;
+ terminal->deleted = 1;
+
+ /* Check for live frames that are still on this terminal. */
FOR_EACH_FRAME (tail, frame)
{
struct frame *f = XFRAME (frame);
initial_terminal = create_terminal ();
initial_terminal->type = output_initial;
initial_terminal->name = xstrdup ("initial_terminal");
+#ifdef MULTI_KBOARD
initial_terminal->kboard = initial_kboard;
-
+#endif
initial_terminal->delete_terminal_hook = &delete_initial_terminal;
/* All other hooks are NULL. */