From 7c0e9cf3d2e83814fab3bb4bb09f7b955c2afaca Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Wed, 5 Feb 2020 21:57:23 -0500 Subject: Add /quit --- chat.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'chat.c') 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(); } -- cgit 1.4.1-2-gfad0