summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-02-12 10:25:04 +0100
committerDominique Martinet <asmadeus@codewreck.org>2017-02-12 10:25:04 +0100
commitbb0e76c4b1146a5bc2e9c10d01f3d4cbf97de966 (patch)
tree03b98d2d65e3e974cbc3da77b82094c6c190dd9e
parent54307f750ea2bcebde61693954977172fcd71721 (diff)
Add pollhup to detect closed stdin
-rw-r--r--tailburst.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tailburst.c b/tailburst.c
index 634dc92..f3b63c9 100644
--- a/tailburst.c
+++ b/tailburst.c
@@ -100,7 +100,7 @@ int main(int argc, char **argv)
fcntl(fd, F_SETFL, flags);
pollfd.fd = fd;
- pollfd.events = POLLIN;
+ pollfd.events = POLLIN | POLLHUP;
while (poll(&pollfd, 1, -1) > 0) {
cur = NULL;
while ((nread = fdgetline(fd, &line)) > 0)
@@ -108,6 +108,9 @@ int main(int argc, char **argv)
if (cur)
printf("%s\n", cur);
+
+ if (pollfd.revents & POLLHUP)
+ break;
}
return 0;