- pthread_create(&thread, NULL, __show_running_run_stats, NULL);
- pthread_detach(thread);
+ fio_mutex_down(stat_mutex);
+
+ if (!pthread_create(&thread, NULL, __show_running_run_stats, NULL)) {
+ pthread_detach(thread);
+ return;
+ }
+
+ fio_mutex_up(stat_mutex);
+}
+
+static int status_interval_init;
+static struct timeval status_time;
+
+#define FIO_STATUS_FILE "/tmp/fio-dump-status"
+
+static int check_status_file(void)
+{
+ struct stat sb;
+
+ if (stat(FIO_STATUS_FILE, &sb))
+ return 0;
+
+ unlink(FIO_STATUS_FILE);
+ return 1;
+}
+
+void check_for_running_stats(void)
+{
+ if (status_interval) {
+ if (!status_interval_init) {
+ fio_gettime(&status_time, NULL);
+ status_interval_init = 1;
+ } else if (mtime_since_now(&status_time) >= status_interval) {
+ show_running_run_stats();
+ fio_gettime(&status_time, NULL);
+ return;
+ }
+ }
+ if (check_status_file()) {
+ show_running_run_stats();
+ return;
+ }