define EXIT_TIMEOUT and use that on ping timeouts. thanks Evan Gates for the idea!

This commit is contained in:
Nico Golde 2016-10-13 15:21:47 -07:00
parent f8f3a096bc
commit 714bd0cb6a

4
ii.c
View File

@ -19,6 +19,8 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#define EXIT_TIMEOUT 2
#ifndef PIPE_BUF /* For OS that doesn't includes PIPE_BUF in limits.h, FreeBSD? */ #ifndef PIPE_BUF /* For OS that doesn't includes PIPE_BUF in limits.h, FreeBSD? */
#define PIPE_BUF _POSIX_PIPE_BUF #define PIPE_BUF _POSIX_PIPE_BUF
#endif #endif
@ -446,7 +448,7 @@ static void run() {
} else if(r == 0) { } else if(r == 0) {
if(time(NULL) - last_response >= PING_TIMEOUT) { if(time(NULL) - last_response >= PING_TIMEOUT) {
print_out(NULL, "-!- ii shutting down: ping timeout"); print_out(NULL, "-!- ii shutting down: ping timeout");
exit(EXIT_FAILURE); exit(EXIT_TIMEOUT);
} }
write(irc, ping_msg, strlen(ping_msg)); write(irc, ping_msg, strlen(ping_msg));
continue; continue;