static struct fio_mutex *startup_mutex;
static volatile int fio_abort;
static int exit_value;
+static struct itimerval itimer;
struct io_log *agg_io_log[2];
}
}
-static void sig_handler(int sig)
+static void status_timer_arm(void)
{
- if (!threads)
- return;
+ itimer.it_value.tv_sec = 0;
+ itimer.it_value.tv_usec = DISK_UTIL_MSEC * 1000;
+ setitimer(ITIMER_REAL, &itimer, NULL);
+}
- switch (sig) {
- case SIGALRM:
+static void sig_alrm(int sig)
+{
+ if (threads) {
update_io_ticks();
- disk_util_timer_arm();
print_thread_status();
- break;
- default:
+ status_timer_arm();
+ }
+}
+
+static void sig_int(int sig)
+{
+ if (threads) {
printf("\nfio: terminating on signal %d\n", sig);
fflush(stdout);
terminate_threads(TERMINATE_ALL);
- break;
}
}
+/*
+ * We need to rearm on BSD/solaris. Switch this to sigaction in the future...
+ */
+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);
+}
+
/*
* Check if we are above the minimum rate given.
*/
fflush(stdout);
}
- signal(SIGINT, sig_handler);
- signal(SIGALRM, sig_handler);
+ set_sig_handlers();
todo = thread_number;
nr_running = 0;
set_genesis_time();
- disk_util_timer_arm();
+ status_timer_arm();
run_threads();