summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'chat.c')
-rw-r--r--chat.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/chat.c b/chat.c
index 162f68f..3402621 100644
--- a/chat.c
+++ b/chat.c
@@ -15,7 +15,9 @@
  */
 
 #include <err.h>
+#include <errno.h>
 #include <locale.h>
+#include <poll.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -98,8 +100,16 @@ int main(int argc, char *argv[]) {
 	ircFormat("NICK :%s\r\n", nick);
 	ircFormat("USER %s 0 * :%s\r\n", user, real);
 
+	struct pollfd fds[2] = {
+		{ .events = POLLIN, .fd = STDIN_FILENO },
+		{ .events = POLLIN, .fd = irc },
+	};
 	for (;;) {
+		int nfds = poll(fds, 2, -1);
+		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
+
+		if (fds[0].revents) uiRead();
+		if (fds[1].revents) ircRecv();
 		uiDraw();
-		ircRecv();
 	}
 }