1
1

Ensure we properly cleanup on termination, including when terminating due to ctrl-c

Signed-off-by: Ralph Castain <rhc@open-mpi.org>
Этот коммит содержится в:
Ralph Castain 2017-06-21 06:33:37 -07:00
родитель c38866eb39
Коммит 38636f4f0a
5 изменённых файлов: 29 добавлений и 28 удалений

Просмотреть файл

@ -342,6 +342,8 @@ int orte_ess_base_app_finalize(void)
(void) mca_base_framework_close(&orte_state_base_framework);
orte_session_dir_finalize(ORTE_PROC_MY_NAME);
/* cleanup the process info */
orte_proc_info_finalize();
return ORTE_SUCCESS;
}

Просмотреть файл

@ -933,6 +933,10 @@ int orte_daemon(int argc, char *argv[])
orte_finalize();
opal_finalize_util();
orte_session_dir_cleanup(ORTE_JOBID_WILDCARD);
/* cleanup the process info */
orte_proc_info_finalize();
if (orte_debug_flag) {
fprintf(stderr, "exiting with status %d\n", orte_exit_status);
}

Просмотреть файл

@ -12,7 +12,7 @@
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
@ -84,9 +84,6 @@ int orte_finalize(void)
orte_schizo.finalize();
(void) mca_base_framework_close(&orte_schizo_base_framework);
/* cleanup the process info */
orte_proc_info_finalize();
/* Close the general debug stream */
opal_output_close(orte_debug_output);

Просмотреть файл

@ -86,6 +86,7 @@
#include "orte/mca/rml/rml.h"
#include "orte/mca/state/state.h"
#include "orte/util/proc_info.h"
#include "orte/util/session_dir.h"
#include "orte/util/show_help.h"
#include "orte/util/threads.h"
@ -222,6 +223,9 @@ int orterun(int argc, char *argv[])
/* cleanup and leave */
orte_submit_finalize();
orte_finalize();
orte_session_dir_cleanup(ORTE_JOBID_WILDCARD);
/* cleanup the process info */
orte_proc_info_finalize();
if (orte_debug_flag) {
fprintf(stderr, "exiting with status %d\n", orte_exit_status);

Просмотреть файл

@ -370,14 +370,12 @@ cleanup:
int
orte_session_dir_cleanup(orte_jobid_t jobid)
{
int rc = ORTE_SUCCESS;
if (!orte_create_session_dirs || orte_process_info.rm_session_dirs ) {
/* we haven't created them or RM will clean them up for us*/
return ORTE_SUCCESS;
}
if (NULL == orte_process_info.job_session_dir ||
if (NULL == orte_process_info.jobfam_session_dir ||
NULL == orte_process_info.proc_session_dir) {
/* this should never happen - it means we are calling
* cleanup *before* properly setting up the session
@ -385,30 +383,20 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
* accidentally removing directories we shouldn't
* touch
*/
rc = ORTE_ERR_NOT_INITIALIZED;
goto CLEANUP;
return ORTE_ERR_NOT_INITIALIZED;
}
/* recursively blow the whole session away for our job family,
* saving only output files
*/
opal_os_dirpath_destroy(orte_process_info.job_session_dir,
opal_os_dirpath_destroy(orte_process_info.jobfam_session_dir,
true, orte_dir_check_file);
/* 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
*/
if( NULL != orte_process_info.top_session_dir ){
opal_os_dirpath_destroy(orte_process_info.top_session_dir,
false, orte_dir_check_file);
}
if (opal_os_dirpath_is_empty(orte_process_info.job_session_dir)) {
if (opal_os_dirpath_is_empty(orte_process_info.jobfam_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found job session dir empty - deleting");
opal_output(0, "sess_dir_cleanup: found jobfam session dir empty - deleting");
}
rmdir(orte_process_info.job_session_dir);
rmdir(orte_process_info.jobfam_session_dir);
} else {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND ==
@ -418,12 +406,10 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
opal_output(0, "sess_dir_cleanup: job session dir not empty - leaving");
}
}
goto CLEANUP;
}
if ( NULL != orte_process_info.top_session_dir ){
if( opal_os_dirpath_is_empty(orte_process_info.top_session_dir) ) {
if (NULL != orte_process_info.top_session_dir) {
if (opal_os_dirpath_is_empty(orte_process_info.top_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
}
@ -440,9 +426,17 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
}
}
CLEANUP:
/* 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
*/
if( NULL != orte_process_info.top_session_dir ){
opal_os_dirpath_destroy(orte_process_info.top_session_dir,
false, orte_dir_check_file);
}
return rc;
return ORTE_SUCCESS;
}