+/*
+ * Happens on thread runs with ctrl-c, ignore our own SIGQUIT
+ */
+static void sig_quit(int sig)
+{
+}
+
+static void sig_int(int sig)
+{
+ if (threads) {
+ log_info("\nfio: terminating on signal %d\n", sig);
+ fflush(stdout);
+ terminate_threads(TERMINATE_ALL);
+ }
+}
+
+static void set_sig_handlers(void)
+{
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = sig_alrm;
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGALRM, &act, NULL);
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = sig_int;
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGINT, &act, NULL);
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = sig_quit;
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGQUIT, &act, NULL);
+}
+