+ int i;
+ for (i = 0; i < argc; i++) {
+ arg->argv[i] = xbt_strdup(argv[i]);
+ }
+ arg->argv[argc] = NULL;
+
+ arg->properties = properties;
+ arg->auto_restart = auto_restart;
+
+ if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
+ && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_name(host))){
+ xbt_dict_set(watched_hosts_lib,sg_host_name(host),host,NULL);
+ XBT_DEBUG("Have pushed host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_name(host));
+ }
+ xbt_dynar_push_as(SIMIX_host_priv(host)->auto_restart_processes,smx_process_arg_t,arg);
+}
+/**
+ * \brief Restart the list of processes that have been registered to the host
+ */
+void SIMIX_host_restart_processes(smx_host_t host)
+{
+ unsigned int cpt;
+ smx_process_arg_t arg;
+ xbt_dynar_t process_list = SIMIX_host_priv(host)->auto_restart_processes;
+ if (!process_list)
+ return;
+
+ xbt_dynar_foreach (process_list, cpt, arg) {
+
+ smx_process_t process;
+
+ XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
+ if (simix_global->create_process_function) {
+ simix_global->create_process_function(&process,
+ arg->argv[0],
+ arg->code,
+ NULL,
+ arg->hostname,
+ arg->kill_time,
+ arg->argc,
+ arg->argv,
+ arg->properties,
+ arg->auto_restart);
+ } else {
+ simcall_process_create(&process,
+ arg->argv[0],
+ arg->code,
+ NULL,
+ arg->hostname,
+ arg->kill_time,
+ arg->argc,
+ arg->argv,
+ arg->properties,
+ arg->auto_restart);
+
+ }
+ /* arg->argv is used by the process created above. Hide it to
+ * _SIMIX_host_free_process_arg() which is called by xbt_dynar_reset()
+ * below. */
+ arg->argc = 0;
+ arg->argv = NULL;
+ }
+ xbt_dynar_reset(process_list);