diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:54 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:54 +0100 |
commit | 07169ff772077f566c6540f623d7d609babc4c81 (patch) | |
tree | 191ed8266e613017d9341c83976c89f4809cc07b /gdb/event-top.c | |
parent | 98d9f24ed15c5ca33bff06647d87b85e22e586d2 (diff) | |
download | binutils-gdb-07169ff772077f566c6540f623d7d609babc4c81.tar.gz |
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/event-top.c')
-rw-r--r-- | gdb/event-top.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/gdb/event-top.c b/gdb/event-top.c index 318da1d32e1..777823ef2ea 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -508,33 +508,45 @@ stdin_event_handler (int error, gdb_client_data client_data) { struct ui *ui = (struct ui *) client_data; - /* Switch to the UI whose input descriptor woke up the event - loop. */ - current_ui = ui; - if (error) { - printf_unfiltered (_("error detected on stdin\n")); + /* Switch to the main UI, so diagnostics always go there. */ + current_ui = main_ui; + delete_file_handler (ui->input_fd); - /* If stdin died, we may as well kill gdb. */ - quit_command ((char *) 0, stdin == ui->instream); + if (main_ui == ui) + { + /* If stdin died, we may as well kill gdb. */ + printf_unfiltered (_("error detected on stdin\n")); + quit_command ((char *) 0, stdin == ui->instream); + } + else + { + /* Simply delete the UI. */ + delete_ui (ui); + } } else { - /* This makes sure a ^C immediately followed by further input is - always processed in that order. E.g,. with input like - "^Cprint 1\n", the SIGINT handler runs, marks the async signal - handler, and then select/poll may return with stdin ready, - instead of -1/EINTR. The - gdb.base/double-prompt-target-event-error.exp test exercises - this. */ + /* Switch to the UI whose input descriptor woke up the event + loop. */ + current_ui = ui; + + /* This makes sure a ^C immediately followed by further input is + always processed in that order. E.g,. with input like + "^Cprint 1\n", the SIGINT handler runs, marks the async + signal handler, and then select/poll may return with stdin + ready, instead of -1/EINTR. The + gdb.base/double-prompt-target-event-error.exp test exercises + this. */ QUIT; do { call_stdin_event_handler_again_p = 0; ui->call_readline (client_data); - } while (call_stdin_event_handler_again_p != 0); + } + while (call_stdin_event_handler_again_p != 0); } } |