+2016-04-12 Pedro Alves <palves@redhat.com>
+
+ * top.c: Include "gdb_select.h".
+ (gdb_readline_no_editing): Wait for input with gdb_select instead
+ of blocking in fgetc.
+ (command_line_input): Don't set immediate_quit.
+
2016-04-08 Martin Galvan <martin.galvan@tallertechnologies.com>
* value.c (value_next): Make pass-by-reference parameters const-correct.
#include "filenames.h"
#include "frame.h"
#include "buffer.h"
+#include "gdb_select.h"
/* readline include files. */
#include "readline/readline.h"
gdb_readline_no_editing (const char *prompt)
{
struct buffer line_buffer;
+ /* Read from stdin if we are executing a user defined command. This
+ is the right thing for prompt_for_continue, at least. */
+ FILE *stream = instream != NULL ? instream : stdin;
+ int fd = fileno (stream);
buffer_init (&line_buffer);
while (1)
{
int c;
+ int numfds;
+ fd_set readfds;
- /* Read from stdin if we are executing a user defined command.
- This is the right thing for prompt_for_continue, at least. */
- c = fgetc (instream ? instream : stdin);
+ QUIT;
+
+ /* Wait until at least one byte of data is available. Control-C
+ can interrupt gdb_select, but not fgetc. */
+ FD_ZERO (&readfds);
+ FD_SET (fd, &readfds);
+ if (gdb_select (fd + 1, &readfds, NULL, NULL, NULL) == -1)
+ {
+ if (errno == EINTR)
+ {
+ /* If this was ctrl-c, the QUIT above handles it. */
+ continue;
+ }
+ perror_with_name (("select"));
+ }
+
+ c = fgetc (stream);
if (c == EOF)
{
/* Starting a new command line. */
cmd_line_buffer.used_size = 0;
- /* Control-C quits instantly if typed while in this loop
- since it should not wait until the user types a newline. */
- immediate_quit++;
- QUIT;
#ifdef STOP_SIGNAL
if (job_control)
signal (STOP_SIGNAL, handle_stop_sig);
if (job_control)
signal (STOP_SIGNAL, SIG_DFL);
#endif
- immediate_quit--;
return cmd;
}