diff options
Diffstat (limited to 'misc/uuidd.c')
-rw-r--r-- | misc/uuidd.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/misc/uuidd.c b/misc/uuidd.c index 6913bf7e..89bff721 100644 --- a/misc/uuidd.c +++ b/misc/uuidd.c @@ -85,19 +85,23 @@ static void create_daemon(void) die("setreuid"); } -static int read_all(int fd, char *buf, size_t count) +static ssize_t read_all(int fd, char *buf, size_t count) { ssize_t ret; - int c = 0; + ssize_t c = 0; + int tries = 0; memset(buf, 0, count); while (count > 0) { ret = read(fd, buf, count); - if (ret < 0) { - if ((errno == EAGAIN) || (errno == EINTR)) + if (ret <= 0) { + if ((errno == EAGAIN || errno == EINTR || ret == 0) && + (tries++ < 5)) continue; - return -1; + return c ? c : -1; } + if (ret > 0) + tries = 0; count -= ret; buf += ret; c += ret; |