summaryrefslogtreecommitdiff
path: root/chat.c
diff options
context:
space:
mode:
authorC. McEnroe2020-02-05 21:57:23 -0500
committerC. McEnroe2020-02-05 21:57:23 -0500
commit7c0e9cf3d2e83814fab3bb4bb09f7b955c2afaca (patch)
tree70adbed2adff0b4639f2a6647c6aa19121aa2f1a /chat.c
parent7c0b60221bf22a8042b584c453bda0e3e87cd0ea (diff)
Add /quit
Diffstat (limited to 'chat.c')
-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();
}