diff options
Diffstat (limited to 'libbb/read.c')
-rw-r--r-- | libbb/read.c | 10 |
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) | |||
88 | while (len) { | 88 | while (len) { |
89 | cc = safe_read(fd, buf, len); | 89 | cc = safe_read(fd, buf, len); |
90 | 90 | ||
91 | if (cc < 0) | 91 | if (cc < 0) { |
92 | return cc; /* read() returns -1 on failure. */ | 92 | if (total) { |
93 | /* we already have some! */ | ||
94 | /* user can do another read to know the error code */ | ||
95 | return total; | ||
96 | } | ||
97 | return cc; /* read() returns -1 on failure. */ | ||
98 | } | ||
93 | if (cc == 0) | 99 | if (cc == 0) |
94 | break; | 100 | break; |
95 | buf = ((char *)buf) + cc; | 101 | buf = ((char *)buf) + cc; |