X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.c;h=d3dacfcfb5300b0d55eb439273c277f2f7c0f0a5;hb=6ec9b87c4ecf5144b5ea845a53a352dd9f2d173a;hp=d7a5b20946d886588e9a8541688f6bfd8cde1d6f;hpb=9d71c4569fbf7068a3a7d7b2a4cf8f05fe5eb067;p=elogind.git diff --git a/src/shared/util.c b/src/shared/util.c index d7a5b2094..d3dacfcfb 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1665,7 +1665,7 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) { errno = 0; - while (nbytes > 0) { + do { ssize_t k; k = write(fd, p, nbytes); @@ -1685,12 +1685,12 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) { return -errno; } - if (k == 0) /* Can't really happen */ + if (nbytes > 0 && k == 0) /* Can't really happen */ return -EIO; p += k; nbytes -= k; - } + } while (nbytes > 0); return 0; }