summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/modem.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/bin/modem.c b/bin/modem.c
index 11b447ea..c099119a 100644
--- a/bin/modem.c
+++ b/bin/modem.c
@@ -65,30 +65,22 @@ int main(int argc, char *argv[]) {
 		err(EX_NOINPUT, "%s", argv[1]);
 	}
 
-	for (;;) {
-		usleep(8 * 1000000 / BAUD_RATE);
-
-		struct pollfd fds[2] = {
-			{ .events = POLLIN, .fd = STDIN_FILENO },
-			{ .events = POLLIN, .fd = pty },
-		};
-		int n = poll(fds, 2, -1);
-		if (n < 0) err(EX_IOERR, "poll");
-
+	char c;
+	struct pollfd fds[2] = {
+		{ .events = POLLIN, .fd = STDIN_FILENO },
+		{ .events = POLLIN, .fd = pty },
+	};
+	while (usleep(8 * 1000000 / BAUD_RATE), 0 < poll(fds, 2, -1)) {
 		if (fds[0].revents) {
-			char c;
 			ssize_t size = read(STDIN_FILENO, &c, 1);
 			if (size < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);
-
 			size = write(pty, &c, 1);
 			if (size < 0) err(EX_IOERR, "write(%d)", pty);
 		}
 
 		if (fds[1].revents) {
-			char c;
 			ssize_t size = read(pty, &c, 1);
 			if (size < 0) err(EX_IOERR, "read(%d)", pty);
-
 			size = write(STDOUT_FILENO, &c, 1);
 			if (size < 0) err(EX_IOERR, "write(%d)", STDOUT_FILENO);
 		}
@@ -98,4 +90,5 @@ int main(int argc, char *argv[]) {
 		if (dead < 0) err(EX_OSERR, "waitpid");
 		if (dead) return WIFEXITED(status) ? WEXITSTATUS(status) : EX_SOFTWARE;
 	}
+	err(EX_IOERR, "poll");
 }
atch.1?id=4e2616bc950822b9d1a6ee8ac46a9d131e75eb89&follow=1'>Generate html for binsJune McEnroe 2019-02-10Use italic for underline in nvim man modeJune McEnroe This doesn't yet work in Terminal.app: <https://github.com/neovim/neovim/issues/9598>. 2019-02-10Add plain text "language" to hiJune McEnroe 2019-02-10Don't match DQ string inside SQ stringJune McEnroe 2019-02-10Skip only one character if a match fails due to parentJune McEnroe Really it should skip forward until the parent changes, but this is simpler. 2019-02-10Remove pattend from hiJune McEnroe 2019-02-10Replace uses of pattend with newline patternsJune McEnroe 2019-02-10Add hi debug outputJune McEnroe 2019-02-10Actually do HTML &quot; escapingJune McEnroe 2019-02-10Set git commit.verboseJune McEnroe 2019-02-10Add back missing static keywordJune McEnroe