aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ser-unix.c')
-rw-r--r--gdb/ser-unix.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index d14a996..0e490fb 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -435,11 +435,41 @@ wait_for(scb, timeout)
fprintf_unfiltered(gdb_stderr, "get_tty_state failed: %s\n", safe_strerror(errno));
#ifdef HAVE_TERMIOS
- state.termios.c_cc[VTIME] = timeout * 10;
+ if (timeout < 0)
+ {
+ /* No timeout. */
+ state.termios.c_cc[VTIME] = 0;
+ state.termios.c_cc[VMIN] = 1;
+ }
+ else
+ {
+ state.termios.c_cc[VMIN] = 0;
+ state.termios.c_cc[VTIME] = timeout * 10;
+ if (state.termios.c_cc[VTIME] != timeout * 10)
+ {
+ warning ("Timeout value %d too large, using %d", timeout,
+ state.termios.c_cc[VTIME] / 10);
+ }
+ }
#endif
#ifdef HAVE_TERMIO
- state.termio.c_cc[VTIME] = timeout * 10;
+ if (timeout < 0)
+ {
+ /* No timeout. */
+ state.termio.c_cc[VTIME] = 0;
+ state.termio.c_cc[VMIN] = 1;
+ }
+ else
+ {
+ state.termio.c_cc[VMIN] = 0;
+ state.termio.c_cc[VTIME] = timeout * 10;
+ if (state.termio.c_cc[VTIME] != timeout * 10)
+ {
+ warning ("Timeout value %d too large, using %d", timeout,
+ state.termio.c_cc[VTIME] / 10);
+ }
+ }
#endif
scb->current_timeout = timeout;