summaryrefslogtreecommitdiffstats
path: root/tailburst.c
diff options
context:
space:
mode:
Diffstat (limited to 'tailburst.c')
-rw-r--r--tailburst.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tailburst.c b/tailburst.c
index f3b63c9..1c621f2 100644
--- a/tailburst.c
+++ b/tailburst.c
@@ -55,6 +55,9 @@ ssize_t fdgetline(int fd, struct getline_states *line) {
line->cur = line->base;
}
+ /* clear errno before read */
+ errno = 0;
+
while ((nread = read(fd, line->base + line->read, line->size - line->read)) > 0 ) {
pr_debug("read %zd\n", nread);
line->read += nread;
@@ -100,7 +103,7 @@ int main(int argc, char **argv)
fcntl(fd, F_SETFL, flags);
pollfd.fd = fd;
- pollfd.events = POLLIN | POLLHUP;
+ pollfd.events = POLLIN;
while (poll(&pollfd, 1, -1) > 0) {
cur = NULL;
while ((nread = fdgetline(fd, &line)) > 0)
@@ -109,7 +112,8 @@ int main(int argc, char **argv)
if (cur)
printf("%s\n", cur);
- if (pollfd.revents & POLLHUP)
+ /* eof */
+ if (nread == 0)
break;
}