+ 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;
+ const char *temp_dir;
+ char fio_status_file_path[PATH_MAX];
+
+ temp_dir = getenv("TMPDIR");
+ if (temp_dir == NULL)
+ temp_dir = getenv("TEMP");
+ if (temp_dir == NULL)
+ temp_dir = "/tmp";
+
+ snprintf(fio_status_file_path, sizeof(fio_status_file_path), "%s/%s", temp_dir, FIO_STATUS_FILE);
+
+ if (stat(fio_status_file_path, &sb))
+ return 0;
+
+ unlink(fio_status_file_path);
+ 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;
+ }