Ensure that stat outputs are serialized

Two issues:

- We don't want potentially two stat outputs running at the same time.
  This could potentially happen if USR1 or interval stats race with
  the thread exit.

- We could potentially crash if the interval or USR1 signaled stat
  output trigger when fio is tearing down. Let the main thread wait
  for any in-progress output in that case.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/stat.h b/stat.h
index b1bf5dc..541b77e 100644
--- a/stat.h
+++ b/stat.h
@@ -199,6 +199,9 @@
 	uint8_t run_str[];
 };
 
+extern void stat_init(void);
+extern void stat_exit(void);
+
 extern void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs);
 extern void show_group_stats(struct group_run_stats *rs);
 extern int calc_thread_status(struct jobs_eta *je, int force);