diff --git a/orte/tools/orte-restart/orte-restart.c b/orte/tools/orte-restart/orte-restart.c index fd286d532e..c33f711aeb 100644 --- a/orte/tools/orte-restart/orte-restart.c +++ b/orte/tools/orte-restart/orte-restart.c @@ -78,6 +78,8 @@ static int check_file(orte_snapc_base_global_snapshot_t *snapshot); static int create_appfile(orte_snapc_base_global_snapshot_t *snapshot); static int spawn_children(orte_snapc_base_global_snapshot_t *snapshot, pid_t *child_pid); static int snapshot_info(orte_snapc_base_global_snapshot_t *snapshot); +static int snapshot_sort_compare_fn(opal_list_item_t **a, + opal_list_item_t **b); /***************************************** * Global Vars for Command line Arguments @@ -495,6 +497,14 @@ static int create_appfile(orte_snapc_base_global_snapshot_t *snapshot) goto cleanup; } + /* + * Sort the snapshots so that they are in order + */ + opal_list_sort(&snapshot->local_snapshots, snapshot_sort_compare_fn); + + /* + * Construct the appfile + */ for(item = opal_list_get_first(&snapshot->local_snapshots); item != opal_list_get_end(&snapshot->local_snapshots); item = opal_list_get_next(item) ) { @@ -732,3 +742,22 @@ int snapshot_info(orte_snapc_base_global_snapshot_t *snapshot) cleanup: return exit_status; } + +static int snapshot_sort_compare_fn(opal_list_item_t **a, + opal_list_item_t **b) +{ + orte_snapc_base_local_snapshot_t *snap_a, *snap_b; + + snap_a = (orte_snapc_base_local_snapshot_t*)(*a); + snap_b = (orte_snapc_base_local_snapshot_t*)(*b); + + if( snap_a->process_name.vpid > snap_b->process_name.vpid ) { + return 1; + } + else if( snap_a->process_name.vpid == snap_b->process_name.vpid ) { + return 0; + } + else { + return -1; + } +}