+2016-04-12 Pedro Alves <palves@redhat.com>
+
+ * ser-base.c (fd_event): Retry read_prim on EINTR.
+ (do_ser_base_readchar): Retry read_prim on EINTR.
+ (ser_base_write): Retry write_prim on EINTR.
+ * ser-unix.c (ser_unix_read_prim): Don't retry on EINTR here.
+ (ser_unix_write_prim): Remove comment.
+
2016-04-12 Pedro Alves <palves@redhat.com>
* remote.c (remote_pass_ctrlc): New function.
pull characters out of the buffer. See also
generic_readchar(). */
int nr;
- nr = scb->ops->read_prim (scb, BUFSIZ);
+
+ do
+ {
+ nr = scb->ops->read_prim (scb, BUFSIZ);
+ }
+ while (nr < 0 && errno == EINTR);
+
if (nr == 0)
{
scb->bufcnt = SERIAL_EOF;
if (status < 0)
return status;
- status = scb->ops->read_prim (scb, BUFSIZ);
+ do
+ {
+ status = scb->ops->read_prim (scb, BUFSIZ);
+ }
+ while (status < 0 && errno == EINTR);
if (status <= 0)
{
cc = scb->ops->write_prim (scb, str, count);
if (cc < 0)
- return 1;
+ {
+ if (errno == EINTR)
+ continue;
+ return 1;
+ }
count -= cc;
str += cc;
}
int
ser_unix_read_prim (struct serial *scb, size_t count)
{
- int status;
-
- while (1)
- {
- status = read (scb->fd, scb->buf, count);
- if (status != -1 || errno != EINTR)
- break;
- }
- return status;
+ return read (scb->fd, scb->buf, count);
}
int
ser_unix_write_prim (struct serial *scb, const void *buf, size_t len)
{
- /* ??? Historically, GDB has not retried calls to "write" that
- result in EINTR. */
return write (scb->fd, buf, len);
}