aboutsummaryrefslogtreecommitdiff
path: root/libbb/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/read.c')
-rw-r--r--libbb/read.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libbb/read.c b/libbb/read.c
index 4ad41d589..575446536 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -88,8 +88,14 @@ ssize_t full_read(int fd, void *buf, size_t len)
while (len) {
cc = safe_read(fd, buf, len);
- if (cc < 0)
- return cc; /* read() returns -1 on failure. */
+ if (cc < 0) {
+ if (total) {
+ /* we already have some! */
+ /* user can do another read to know the error code */
+ return total;
+ }
+ return cc; /* read() returns -1 on failure. */
+ }
if (cc == 0)
break;
buf = ((char *)buf) + cc;