aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/read_printf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libbb/read_printf.c b/libbb/read_printf.c
index 5ed6e3632..b6a17cc36 100644
--- a/libbb/read_printf.c
+++ b/libbb/read_printf.c
@@ -45,20 +45,20 @@
45 * which detects EAGAIN and uses poll() to wait on the fd. 45 * which detects EAGAIN and uses poll() to wait on the fd.
46 * Thankfully, poll() doesn't care about O_NONBLOCK flag. 46 * Thankfully, poll() doesn't care about O_NONBLOCK flag.
47 */ 47 */
48ssize_t FAST_FUNC nonblock_immune_read(int fd, void *buf, size_t count, int loop_on_EINTR) 48ssize_t FAST_FUNC nonblock_immune_read(int fd, void *buf, size_t count)
49{ 49{
50 struct pollfd pfd[1]; 50 struct pollfd pfd[1];
51 ssize_t n; 51 ssize_t n;
52 52
53 while (1) { 53 while (1) {
54 n = loop_on_EINTR ? safe_read(fd, buf, count) : read(fd, buf, count); 54 n = safe_read(fd, buf, count);
55 if (n >= 0 || errno != EAGAIN) 55 if (n >= 0 || errno != EAGAIN)
56 return n; 56 return n;
57 /* fd is in O_NONBLOCK mode. Wait using poll and repeat */ 57 /* fd is in O_NONBLOCK mode. Wait using poll and repeat */
58 pfd[0].fd = fd; 58 pfd[0].fd = fd;
59 pfd[0].events = POLLIN; 59 pfd[0].events = POLLIN;
60 /* note: safe_poll pulls in printf */ 60 /* note: safe_poll pulls in printf */
61 loop_on_EINTR ? safe_poll(pfd, 1, -1) : poll(pfd, 1, -1); 61 safe_poll(pfd, 1, -1);
62 } 62 }
63} 63}
64 64
@@ -81,7 +81,7 @@ char* FAST_FUNC xmalloc_reads(int fd, size_t *maxsz_p)
81 p = buf + sz; 81 p = buf + sz;
82 sz += 128; 82 sz += 128;
83 } 83 }
84 if (nonblock_immune_read(fd, p, 1, /*loop_on_EINTR:*/ 1) != 1) { 84 if (nonblock_immune_read(fd, p, 1) != 1) {
85 /* EOF/error */ 85 /* EOF/error */
86 if (p == buf) { /* we read nothing */ 86 if (p == buf) { /* we read nothing */
87 free(buf); 87 free(buf);