about summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-05 21:57:23 -0500
committerJune McEnroe <june@causal.agency>2020-02-05 21:57:23 -0500
commit7c0e9cf3d2e83814fab3bb4bb09f7b955c2afaca (patch)
tree70adbed2adff0b4639f2a6647c6aa19121aa2f1a /chat.c
parentAdd /me, /notice, /quote commands (diff)
downloadcatgirl-7c0e9cf3d2e83814fab3bb4bb09f7b955c2afaca.tar.gz
catgirl-7c0e9cf3d2e83814fab3bb4bb09f7b955c2afaca.zip
Add /quit
Diffstat (limited to '')
-rw-r--r--chat.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/chat.c b/chat.c
index 2d58b1e..1ad2833 100644
--- a/chat.c
+++ b/chat.c
@@ -115,13 +115,12 @@ int main(int argc, char *argv[]) {
 		{ .events = POLLIN, .fd = STDIN_FILENO },
 		{ .events = POLLIN, .fd = irc },
 	};
-	for (;;) {
+	while (!self.quit) {
 		int nfds = poll(fds, 2, -1);
 		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
 
-		if (signals[SIGHUP] || signals[SIGINT] || signals[SIGTERM]) {
-			break;
-		}
+		if (signals[SIGHUP]) self.quit = "zzz";
+		if (signals[SIGINT] || signals[SIGTERM]) break;
 		if (signals[SIGWINCH]) {
 			signals[SIGWINCH] = 0;
 			cursesWinch(SIGWINCH);
@@ -136,6 +135,10 @@ int main(int argc, char *argv[]) {
 		uiDraw();
 	}
 
-	ircFormat("QUIT\r\n");
+	if (self.quit) {
+		ircFormat("QUIT :%s\r\n", self.quit);
+	} else {
+		ircFormat("QUIT\r\n");
+	}
 	uiHide();
 }