src/util/session_dir.c
/*
 * A job has aborted - so force cleanup of the session directory
 */
A job has aborted - so force cleanup of the session directory
A job has aborted - so force cleanup of the session directory
int prte_session_dir_cleanup(pmix_nspace_t jobid)
{
    PRTE_HIDE_UNUSED_PARAMS(jobid);
    if (prte_ras_base.launch_orted_on_hn && PRTE_PROC_IS_DAEMON && 1 == PRTE_PROC_MY_NAME->rank) {
        return PRTE_SUCCESS;
    }
    if (!prte_create_session_dirs || prte_process_info.rm_session_dirs) {
        return PRTE_SUCCESS;
    }
    if (NULL == prte_process_info.jobfam_session_dir
        || NULL == prte_process_info.proc_session_dir) {
        return PRTE_ERR_NOT_INITIALIZED;
    }
    prte_os_dirpath_destroy(prte_process_info.jobfam_session_dir, true, prte_dir_check_file);
    if (prte_os_dirpath_is_empty(prte_process_info.jobfam_session_dir)) {
        if (prte_debug_flag) {
            prte_output(0, "sess_dir_cleanup: found jobfam session dir empty - deleting");
        }
        rmdir(prte_process_info.jobfam_session_dir);
    } else {
        if (prte_debug_flag) {
            if (PRTE_ERR_NOT_FOUND
                == prte_os_dirpath_access(prte_process_info.job_session_dir, 0)) {
                prte_output(0, "sess_dir_cleanup: job session dir does not exist");
            } else {
                prte_output(0, "sess_dir_cleanup: job session dir not empty - leaving");
            }
        }
    }
    if (NULL != prte_process_info.top_session_dir) {
        if (prte_os_dirpath_is_empty(prte_process_info.top_session_dir)) {
            if (prte_debug_flag) {
                prte_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
            }
            rmdir(prte_process_info.top_session_dir);
        } else {
            if (prte_debug_flag) {
                if (PRTE_ERR_NOT_FOUND
                    == prte_os_dirpath_access(prte_process_info.top_session_dir, 0)) {
                    prte_output(0, "sess_dir_cleanup: top session dir does not exist");
                } else {
                    prte_output(0, "sess_dir_cleanup: top session dir not empty - leaving");
                }
            }
        }
    }
    if (NULL != prte_process_info.top_session_dir) {
        prte_os_dirpath_destroy(prte_process_info.top_session_dir, false, prte_dir_check_file);
    }
    return PRTE_SUCCESS;
}
int prte_session_dir_cleanup ( pmix_nspace_t jobid ) { PRTE_HIDE_UNUSED_PARAMS ( jobid ) ; if ( prte_ras_base . launch_orted_on_hn && PRTE_PROC_IS_DAEMON && 1 == PRTE_PROC_MY_NAME -> rank ) { return PRTE_SUCCESS ; } if ( ! prte_create_session_dirs || prte_process_info . rm_session_dirs ) { return PRTE_SUCCESS ; } if ( NULL == prte_process_info . jobfam_session_dir || NULL == prte_process_info . proc_session_dir ) { return PRTE_ERR_NOT_INITIALIZED ; } prte_os_dirpath_destroy ( prte_process_info . jobfam_session_dir , true , prte_dir_check_file ) ; if ( prte_os_dirpath_is_empty ( prte_process_info . jobfam_session_dir ) ) { if ( prte_debug_flag ) { prte_output ( 0 , " " ) ; } rmdir ( prte_process_info . jobfam_session_dir ) ; } else { if ( prte_debug_flag ) { if ( PRTE_ERR_NOT_FOUND == prte_os_dirpath_access ( prte_process_info . job_session_dir , 0 ) ) { prte_output ( 0 , " " ) ; } else { prte_output ( 0 , " " ) ; } } } if ( NULL != prte_process_info . top_session_dir ) { if ( prte_os_dirpath_is_empty ( prte_process_info . top_session_dir ) ) { if ( prte_debug_flag ) { prte_output ( 0 , " " ) ; } rmdir ( prte_process_info . top_session_dir ) ; } else { if ( prte_debug_flag ) { if ( PRTE_ERR_NOT_FOUND == prte_os_dirpath_access ( prte_process_info . top_session_dir , 0 ) ) { prte_output ( 0 , " " ) ; } else { prte_output ( 0 , " " ) ; } } } } if ( NULL != prte_process_info . top_session_dir ) { prte_os_dirpath_destroy ( prte_process_info . top_session_dir , false , prte_dir_check_file ) ; } return PRTE_SUCCESS ; }
A job has aborted - so force cleanup of the session directory
A job has aborted - so force cleanup of the session directory
/* special case - if a daemon is colocated with mpirun,
     * then we let mpirun do the rest to avoid a race
     * condition. this scenario always results in the rank=1
     * daemon colocated with mpirun */ /* we haven't created them or RM will clean them up for us*/ /* this should never happen - it means we are calling
         * cleanup *before* properly setting up the session
         * dir system. This leaves open the possibility of
         * accidentally removing directories we shouldn't
         * touch
         */ /* recursively blow the whole session away for our job family,
     * saving only output files
     */ /* now attempt to eliminate the top level directory itself - this
     * will fail if anything is present, but ensures we cleanup if
     * we are the last one out
     */