2017-02-21 Gareth McMullin PR remote/21188 * ser-unix.c (do_hardwire_readchar): Wait for full timeout to elapse. diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index b9e55f0..0a74672 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -549,6 +549,18 @@ do_hardwire_readchar (struct serial *scb, int timeout) scb->timeout_remaining = (timeout < 0 ? timeout : timeout - delta); status = wait_for (scb, delta); + if (status == SERIAL_TIMEOUT) { + if (scb->timeout_remaining > 0) + { + timeout = scb->timeout_remaining; + continue; + } + else if (scb->timeout_remaining < 0) + continue; + else + return SERIAL_TIMEOUT; + } + if (status < 0) return status; @@ -556,21 +568,7 @@ do_hardwire_readchar (struct serial *scb, int timeout) if (status <= 0) { - if (status == 0) - { - /* Zero characters means timeout (it could also be EOF, but - we don't (yet at least) distinguish). */ - if (scb->timeout_remaining > 0) - { - timeout = scb->timeout_remaining; - continue; - } - else if (scb->timeout_remaining < 0) - continue; - else - return SERIAL_TIMEOUT; - } - else if (errno == EINTR) + if (errno == EINTR) continue; else return SERIAL_ERROR; /* Got an error from read. */