+
+/* When there is an event ready on the stdin file desriptor, instead
+ of calling readline directly throught the callback function, or
+ instead of calling gdb_readline2, give gdb a chance to detect
+ errors and do something. */
+void
+stdin_event_handler (int error, gdb_client_data client_data)
+{
+ if (error)
+ {
+ printf_unfiltered ("error detected on stdin\n");
+ delete_file_handler (input_fd);
+ discard_all_continuations ();
+ /* If stdin died, we may as well kill gdb. */
+ quit_command ((char *) 0, stdin == instream);
+ }
+ else
+ (*call_readline) (client_data);
+}
+
+/* Re-enable stdin after the end of an execution command in
+ synchronous mode, or after an error from the target, and we aborted
+ the exec operation. */
+
+void
+async_enable_stdin (void *dummy)
+{
+ /* See NOTE in async_disable_stdin() */
+ /* FIXME: cagney/1999-09-27: Call this before clearing
+ sync_execution. Current target_terminal_ours() implementations
+ check for sync_execution before switching the terminal. */
+ target_terminal_ours ();
+ pop_prompt ();
+ sync_execution = 0;
+}
+
+/* Disable reads from stdin (the console) marking the command as
+ synchronous. */
+
+void
+async_disable_stdin (void)
+{
+ sync_execution = 1;
+ push_prompt ("", "", "");
+ /* FIXME: cagney/1999-09-27: At present this call is technically
+ redundant since infcmd.c and infrun.c both already call
+ target_terminal_inferior(). As the terminal handling (in
+ sync/async mode) is refined, the duplicate calls can be
+ eliminated (Here or in infcmd.c/infrun.c). */
+ target_terminal_inferior ();
+ /* Add the reinstate of stdin to the list of cleanups to be done
+ in case the target errors out and dies. These cleanups are also
+ done in case of normal successful termination of the execution
+ command, by complete_execution(). */
+ make_exec_error_cleanup (async_enable_stdin, NULL);
+}