Async signal handlers have no connection to whichever was the current
UI, and thus always run on the main one.
gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>
	* event-loop.c: Include top.h.
	(invoke_async_signal_handlers): Switch to the main UI.
	* event-top.c (main_ui_): Update comment.
	(main_ui): New global.
	* top.h (main_ui): Declare.
 #include "gdb_sys_time.h"
 #include "gdb_select.h"
 #include "observer.h"
+#include "top.h"
 
 /* Tell create_file_handler what events we are interested in.
    This is used by the select version of the event loop.  */
        break;
       any_ready = 1;
       async_handler_ptr->ready = 0;
+      /* Async signal handlers have no connection to whichever was the
+        current UI, and thus always run on the main one.  */
+      current_ui = main_ui;
       (*async_handler_ptr->proc) (async_handler_ptr->client_data);
     }
 
 
   return xstrdup (prompt);
 }
 
-/* The main UI.  This is the UI that is bound to stdin/stdout/stderr.
-   It always exists and is created automatically when GDB starts
-   up.  */
+/* The main UI.  */
 static struct ui main_ui_;
 
+struct ui *main_ui = &main_ui_;
 struct ui *current_ui = &main_ui_;
 struct ui *ui_list = &main_ui_;
 
 
   struct ui_file *m_gdb_stdlog;
 };
 
+/* The main UI.  This is the UI that is bound to stdin/stdout/stderr.
+   It always exists and is created automatically when GDB starts
+   up.  */
+extern struct ui *main_ui;
+
 /* The current UI.  */
 extern struct ui *current_ui;