aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-06-21 01:11:54 +0100
committerPedro Alves <palves@redhat.com>2016-06-21 01:11:54 +0100
commit07169ff772077f566c6540f623d7d609babc4c81 (patch)
tree191ed8266e613017d9341c83976c89f4809cc07b /gdb/top.c
parent98d9f24ed15c5ca33bff06647d87b85e22e586d2 (diff)
downloadgdb-07169ff772077f566c6540f623d7d609babc4c81.zip
gdb-07169ff772077f566c6540f623d7d609babc4c81.tar.gz
gdb-07169ff772077f566c6540f623d7d609babc4c81.tar.bz2
Handle UI's terminal closing
Without this, GDB exits if a secondary UIs terminal/input stream is closed: $ ./gdb -ex "new-ui mi /dev/pts/6" New UI allocated <<< close /dev/pts/6 (gdb) Error detected on fd 9 $ We want that for the main UI, but not secondary UIs. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * event-top.c (stdin_event_handler): Don't quit gdb if it was a secondary UI's input stream that closed. Instead, just delete the UI.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/top.c b/gdb/top.c
index c5e237d..5883875 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -286,6 +286,37 @@ new_ui (FILE *instream, FILE *outstream, FILE *errstream)
return ui;
}
+static void
+free_ui (struct ui *ui)
+{
+ ui_file_delete (ui->m_gdb_stdin);
+ ui_file_delete (ui->m_gdb_stdout);
+ ui_file_delete (ui->m_gdb_stderr);
+
+ xfree (ui);
+}
+
+void
+delete_ui (struct ui *todel)
+{
+ struct ui *ui, *uiprev;
+
+ uiprev = NULL;
+
+ for (ui = ui_list; ui != NULL; uiprev = ui, ui = ui->next)
+ if (ui == todel)
+ break;
+
+ gdb_assert (ui != NULL);
+
+ if (uiprev != NULL)
+ uiprev->next = ui->next;
+ else
+ ui_list = ui->next;
+
+ free_ui (ui);
+}
+
/* Handler for SIGHUP. */
#ifdef SIGHUP