+static int __check_trigger_file(void)
+{
+ struct stat sb;
+
+ if (!trigger_file)
+ return 0;
+
+ if (stat(trigger_file, &sb))
+ return 0;
+
+ if (unlink(trigger_file) < 0)
+ log_err("fio: failed to unlink %s: %s\n", trigger_file,
+ strerror(errno));
+
+ return 1;
+}
+
+static int trigger_timedout(void)
+{
+ if (trigger_timeout)
+ return time_since_genesis() >= trigger_timeout;
+
+ return 0;
+}
+
+void exec_trigger(const char *cmd)
+{
+ int ret;
+
+ if (!cmd)
+ return;
+
+ ret = system(cmd);
+ if (ret == -1)
+ log_err("fio: failed executing %s trigger\n", cmd);
+}
+
+void check_trigger_file(void)
+{
+ if (__check_trigger_file() || trigger_timedout()) {
+ if (nr_clients)
+ fio_clients_send_trigger(trigger_remote_cmd);
+ else {
+ verify_save_state();
+ fio_terminate_threads(TERMINATE_ALL);
+ exec_trigger(trigger_cmd);
+ }
+ }
+}
+
+static int fio_verify_load_state(struct thread_data *td)
+{
+ int ret;
+
+ if (!td->o.verify_state)
+ return 0;
+
+ if (is_backend) {
+ void *data;
+
+ ret = fio_server_get_verify_state(td->o.name,
+ td->thread_number - 1, &data);
+ if (!ret)
+ verify_convert_assign_state(td, data);
+ } else
+ ret = verify_load_state(td, "local");
+
+ return ret;
+}
+