summaryrefslogtreecommitdiff
path: root/gdb/ui-file.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2009-11-13 22:54:41 +0000
committerDaniel Jacobowitz <dan@debian.org>2009-11-13 22:54:41 +0000
commit817a438bd5623f35e3b527c033e0874f46fe5384 (patch)
treef9992cf77ed124b77997b9fc37b2ed0596638f28 /gdb/ui-file.c
parent441998e3cb81532c514353974508143932bed4a7 (diff)
downloadgdb-817a438bd5623f35e3b527c033e0874f46fe5384.tar.gz
* ui-file.c (stdio_file_read): Call gdb_select before read.
Diffstat (limited to 'gdb/ui-file.c')
-rw-r--r--gdb/ui-file.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 527917c414f..b9ddbb5c5a7 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -23,6 +23,7 @@
#include "defs.h"
#include "ui-file.h"
#include "gdb_string.h"
+#include "gdb_select.h"
#include <errno.h>
@@ -471,6 +472,19 @@ stdio_file_read (struct ui_file *file, char *buf, long length_buf)
if (stdio->magic != &stdio_file_magic)
internal_error (__FILE__, __LINE__,
_("stdio_file_read: bad magic number"));
+
+ /* For the benefit of Windows, call gdb_select before reading from
+ the file. Wait until at least one byte of data is available.
+ Control-C can interrupt gdb_select, but not read. */
+ {
+ int fd = fileno (stdio->file);
+ fd_set readfds;
+ FD_ZERO (&readfds);
+ FD_SET (fd, &readfds);
+ if (gdb_select (fd + 1, &readfds, NULL, NULL, NULL) == -1)
+ return -1;
+ }
+
return read (fileno (stdio->file), buf, length_buf);
}