summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-06-03 10:34:51 -0400
committerJune McEnroe <june@causal.agency>2022-06-03 10:34:51 -0400
commitae064a619bb3972f0c12840e7d8950ac025fea1c (patch)
tree7cf68687e97d4541ee7ce2a5a1b56a62554a464f
parentSet TABSIZE=4 (diff)
downloadsrc-ae064a619bb3972f0c12840e7d8950ac025fea1c.tar.gz
src-ae064a619bb3972f0c12840e7d8950ac025fea1c.zip
Stop polling stdin after EOF
-rw-r--r--bin/qf.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/qf.c b/bin/qf.c
index 0975cea8..aac44fa5 100644
--- a/bin/qf.c
+++ b/bin/qf.c
@@ -249,18 +249,22 @@ int main(int argc, char *argv[]) {
 	}
 	curse();
 	struct pollfd fds[2] = {
-		{ .fd = STDIN_FILENO, .events = POLLIN },
 		{ .fd = STDERR_FILENO, .events = POLLIN },
+		{ .fd = STDIN_FILENO, .events = POLLIN },
 	};
+	int nfds = 2;
 	size_t len = 0;
 	size_t cap = 4096;
 	char *buf = malloc(cap);
 	if (!buf) err(EX_OSERR, "malloc");
-	while (poll(fds, 2, -1)) {
+	while (poll(fds, nfds, -1)) {
 		if (fds[0].revents) {
-			ssize_t n = read(fds[0].fd, &buf[len], cap - len);
+			input();
+		}
+		if (nfds > 1 && fds[1].revents) {
+			ssize_t n = read(fds[1].fd, &buf[len], cap - len);
 			if (n < 0) err(EX_IOERR, "read");
-			if (!n) fds[0].events = 0;
+			if (!n) nfds--;
 			len += n;
 			char *ptr = buf;
 			for (
@@ -280,9 +284,6 @@ int main(int argc, char *argv[]) {
 				if (!buf) err(EX_OSERR, "realloc");
 			}
 		}
-		if (fds[1].revents) {
-			input();
-		}
 		draw();
 	}
 	err(EX_IOERR, "poll");
June McEnroe 2020-08-23Update litterbox version rangeJune McEnroe 2020-08-19Set a database busy timeoutJune McEnroe 2020-07-29Add Linux supportJune McEnroe Static linking on Linux (even with musl-gcc) is just too much of a pain. People more dedicated than I am can figure it out themselves. Or how to properly sandbox this without a chroot. 2020-07-29Remove unused prevEventJune McEnroe 2020-07-23Rewrite configure scriptJune McEnroe 2020-07-21Add OpenBSD instructionsJune McEnroe 2020-07-21Use a .pc file to configureJune McEnroe 2020-07-19Filter networks with only private contexts from recents as wellJune McEnroe 2020-07-18Specify litterbox version in readmeJune McEnroe 2020-07-18Reverse order of X macro parameters for pages and keysJune McEnroe 2020-07-18Remove kcgi 0.11 compatibilityJune McEnroe 2020-07-17Filter networks with only private contextsJune McEnroe 2020-07-17Add export optionJune McEnroe Adding the export query parameter to any page downloads a .html with the default stylesheet embedded, and all navigation, forms and internal links removed, for being able to share some part of a private instance of litterbox. 2020-07-17Add margin to inputsJune McEnroe Seems that only Safari provides any margins on form elements by default. 2020-07-16Don't write null terminator in stylesheet responseJune McEnroe 2020-07-16Remove sudo from make installJune McEnroe