src/mca/odls/base/odls_base_frame.c
/**
 * Function for finding and opening either all MCA components, or the one
 * that was specifically requested via a MCA parameter.
 */
Function for finding and opening either all MCA components, or the one
that was specifically requested via a MCA parameter.
Function for finding and opening either all MCA components or the one that was specifically requested via a MCA parameter .
static int prte_odls_base_open(prte_mca_base_open_flag_t flags)
{
    char **ranks = NULL, *tmp;
    int rc, i, rank;
    prte_namelist_t *nm;
    bool xterm_hold;
    sigset_t unblock;
    PRTE_CONSTRUCT_LOCK(&prte_odls_globals.lock);
    prte_odls_globals.lock.active = false; 
    prte_local_children = PRTE_NEW(prte_pointer_array_t);
    if (PRTE_SUCCESS
        != (rc = prte_pointer_array_init(prte_local_children, 1, PRTE_GLOBAL_ARRAY_MAX_SIZE, 1))) {
        PRTE_ERROR_LOG(rc);
        return rc;
    }
    PRTE_CONSTRUCT(&prte_odls_globals.xterm_ranks, prte_list_t);
    prte_odls_globals.xtermcmd = NULL;
    if (0 != sigemptyset(&unblock)) {
        return PRTE_ERROR;
    }
    if (0 != sigaddset(&unblock, SIGCHLD)) {
        return PRTE_ERROR;
    }
    if (0 != sigprocmask(SIG_UNBLOCK, &unblock, NULL)) {
        return PRTE_ERR_NOT_SUPPORTED;
    }
    if (NULL != prte_xterm) {
        xterm_hold = false;
        prte_util_parse_range_options(prte_xterm, &ranks);
        for (i = 0; i < prte_argv_count(ranks); i++) {
            if (0 == strcmp(ranks[i], "BANG")) {
                xterm_hold = true;
                continue;
            }
            nm = PRTE_NEW(prte_namelist_t);
            rank = strtol(ranks[i], NULL, 10);
            if (-1 == rank) {
                nm->name.rank = PMIX_RANK_WILDCARD;
            } else if (rank < 0) {
                prte_show_help("help-prte-odls-base.txt", "prte-odls-base:xterm-neg-rank", true,
                               rank);
                return PRTE_ERROR;
            } else {
                nm->name.rank = rank;
            }
            prte_list_append(&prte_odls_globals.xterm_ranks, &nm->super);
        }
        prte_argv_free(ranks);
        prte_odls_globals.xtermcmd = NULL;
        tmp = prte_find_absolute_path("xterm");
        if (NULL == tmp) {
            return PRTE_ERROR;
        }
        prte_argv_append_nosize(&prte_odls_globals.xtermcmd, tmp);
        free(tmp);
        prte_argv_append_nosize(&prte_odls_globals.xtermcmd, "-T");
        prte_argv_append_nosize(&prte_odls_globals.xtermcmd, "save");
        if (xterm_hold) {
            prte_argv_append_nosize(&prte_odls_globals.xtermcmd, "-hold");
        }
        prte_argv_append_nosize(&prte_odls_globals.xtermcmd, "-e");
    }
    return prte_mca_base_framework_components_open(&prte_odls_base_framework, flags);
}
static int prte_odls_base_open ( prte_mca_base_open_flag_t flags ) { char * * ranks = NULL , * tmp ; int rc , i , rank ; prte_namelist_t * nm ; bool xterm_hold ; sigset_t unblock ; PRTE_CONSTRUCT_LOCK ( & prte_odls_globals . lock ) ; prte_odls_globals . lock . active = false ; prte_local_children = PRTE_NEW ( prte_pointer_array_t ) ; if ( PRTE_SUCCESS != ( rc = prte_pointer_array_init ( prte_local_children , 1 , PRTE_GLOBAL_ARRAY_MAX_SIZE , 1 ) ) ) { PRTE_ERROR_LOG ( rc ) ; return rc ; } PRTE_CONSTRUCT ( & prte_odls_globals . xterm_ranks , prte_list_t ) ; prte_odls_globals . xtermcmd = NULL ; if ( 0 != sigemptyset ( & unblock ) ) { return PRTE_ERROR ; } if ( 0 != sigaddset ( & unblock , SIGCHLD ) ) { return PRTE_ERROR ; } if ( 0 != sigprocmask ( SIG_UNBLOCK , & unblock , NULL ) ) { return PRTE_ERR_NOT_SUPPORTED ; } if ( NULL != prte_xterm ) { xterm_hold = false ; prte_util_parse_range_options ( prte_xterm , & ranks ) ; for ( i = 0 ; i < prte_argv_count ( ranks ) ; i ++ ) { if ( 0 == strcmp ( ranks [ i ] , " " ) ) { xterm_hold = true ; continue ; } nm = PRTE_NEW ( prte_namelist_t ) ; rank = strtol ( ranks [ i ] , NULL , 10 ) ; if ( -1 == rank ) { nm -> name . rank = PMIX_RANK_WILDCARD ; } else if ( rank < 0 ) { prte_show_help ( " " , " " , true , rank ) ; return PRTE_ERROR ; } else { nm -> name . rank = rank ; } prte_list_append ( & prte_odls_globals . xterm_ranks , & nm -> super ) ; } prte_argv_free ( ranks ) ; prte_odls_globals . xtermcmd = NULL ; tmp = prte_find_absolute_path ( " " ) ; if ( NULL == tmp ) { return PRTE_ERROR ; } prte_argv_append_nosize ( & prte_odls_globals . xtermcmd , tmp ) ; free ( tmp ) ; prte_argv_append_nosize ( & prte_odls_globals . xtermcmd , " " ) ; prte_argv_append_nosize ( & prte_odls_globals . xtermcmd , " " ) ; if ( xterm_hold ) { prte_argv_append_nosize ( & prte_odls_globals . xtermcmd , " " ) ; } prte_argv_append_nosize ( & prte_odls_globals . xtermcmd , " " ) ; } return prte_mca_base_framework_components_open ( & prte_odls_base_framework , flags ) ; }
Function for finding and opening either all MCA components, or the one
 that was specifically requested via a MCA parameter.
Function for finding and opening either all MCA components or the one that was specifically requested via a MCA parameter .
// start with nobody having the thread /* initialize the global array of local children */ /* initialize ODLS globals */ /* ensure that SIGCHLD is unblocked as we need to capture it */ /* check if the user requested that we display output in xterms */ /* construct a list of ranks to be displayed */ /* wildcard */ /* error out on bozo case */ /* we can't check here if the rank is out of
                 * range as we don't yet know how many ranks
                 * will be in the job - we'll check later
                 */ /* construct the xtermcmd */ /* Open up all available components */