summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-10-26 20:34:07 +0100
committerLars Wirzenius <liw@liw.fi>2010-10-26 20:34:07 +0100
commit1a2d07426d4bb164fc120979e2e62f95f56d551d (patch)
tree04cfaba802f4e03b2b7876019c6b56280da97c69
parent85270841ad91bab30efe89c083dd547cc928283c (diff)
downloaddynstr-1a2d07426d4bb164fc120979e2e62f95f56d551d.tar.gz
Handle EAGAIN errors when reading from file descriptors.
-rw-r--r--dynstr.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/dynstr.c b/dynstr.c
index 339cf47..ac276ae 100644
--- a/dynstr.c
+++ b/dynstr.c
@@ -402,8 +402,10 @@ static size_t fread_callback(FILE *f, int fd, unsigned char *buf, size_t size)
static size_t read_callback(FILE *f, int fd, unsigned char *buf, size_t size)
{
ssize_t n;
-
- n = read(fd, buf, size);
+
+ do {
+ n = read(fd, buf, size);
+ } while (n == -1 && errno == EAGAIN);
if (n == -1)
return DYNSTR_ERROR;
return n;
@@ -511,8 +513,10 @@ static int readline_callback(FILE *f, int fd)
{
unsigned char c;
int n;
-
- n = read(fd, &c, 1);
+
+ do {
+ n = read(fd, &c, 1);
+ } while (n == -1 && errno == EAGAIN);
if (n == 0)
return -2;
else if (n == -1)