int fld_index[FLD_INDEX_SZ]; /* default display field (defined by key in net.h) and order */
char available_options[MAXFLD];
int display_offset; /* only used in text mode */
+ int Interrupted;
void *gtk_data; /* pointer to hold arbitrary gtk data */
unsigned int /* bit field to hold named booleans */
ForceMaxPing:1,
#include <string.h>
#include <math.h>
#include <errno.h>
+#include <signal.h>
#ifdef HAVE_ERROR_H
#include <error.h>
#else
#define MIN_DISPLAY_REDRAW_USEC 100000
+static volatile sig_atomic_t interrupted;
+
+static void interrupt_handler(
+ int signum ATTRIBUTE_UNUSED)
+{
+ interrupted = 1;
+}
+
+
static int timeval_after_or_equal(
const struct timeval *a,
const struct timeval *b)
struct timeval intervaltime;
static double dnsinterval = 0;
+ interrupted = 0;
+ signal(SIGINT, interrupt_handler);
+
memset(&startgrace, 0, sizeof(startgrace));
gettimeofday(&lasttime, NULL);
nextredraw = lasttime;
while (1) {
+ if (interrupted) {
+ ctl->Interrupted = 1;
+ return;
+ }
+
dt = calc_deltatime(ctl->WaitTime);
intervaltime.tv_sec = dt / 1000000;
intervaltime.tv_usec = dt % 1000000;
rv = select(maxfd, (void *) &readfd, NULL, NULL,
&selecttime);
}
- } while ((rv < 0) && (errno == EINTR));
+ } while ((rv < 0) && (errno == EINTR) && !interrupted);
+
+ if (interrupted) {
+ ctl->Interrupted = 1;
+ return;
+ }
if (rv < 0) {
error(EXIT_FAILURE, errno, "Select failed");