summary refs log tree commit diff
path: root/rvnit.c
diff options
context:
space:
mode:
Diffstat (limited to 'rvnit.c')
-rw-r--r--rvnit.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/rvnit.c b/rvnit.c
index c7b9038..8c7b36b 100644
--- a/rvnit.c
+++ b/rvnit.c
@@ -452,6 +452,7 @@ logger_loop(void* ignored)
 
 			if ((fds[j].revents & (POLLHUP | POLLERR)) &&
 			    !(fds[j].revents & POLLIN)) {
+closed_pipe:
 				/* write end was closed, close whole pipe */
 				pthread_mutex_lock(&services_lock);
 				for (int i = 0; i < MAX_SV; i++) {
@@ -482,6 +483,12 @@ logger_loop(void* ignored)
 				continue;
 			}
 
+			if (rd == 0) {
+				// some OS set POLLIN|POLLHUP on closed pipes
+				// https://www.greenend.org.uk/rjk/tech/poll.html
+				goto closed_pipe;
+			}
+
 			if (rd < (int)sizeof buf && buf[rd - 1] != '\n') {
 				// sometimes processes use multiple write calls
 				// for one line, give them 25msec to do try to