Skip to content

Commit 0f54799

Browse files
author
Ralph Castain
authored
Merge pull request #3725 from rhc54/topic/cleanup
Ensure we properly cleanup on termination, including when terminating due to ctrl-c
2 parents c38866e + 38636f4 commit 0f54799

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

orte/mca/ess/base/ess_base_std_app.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ int orte_ess_base_app_finalize(void)
342342
(void) mca_base_framework_close(&orte_state_base_framework);
343343

344344
orte_session_dir_finalize(ORTE_PROC_MY_NAME);
345+
/* cleanup the process info */
346+
orte_proc_info_finalize();
345347

346348
return ORTE_SUCCESS;
347349
}

orte/orted/orted_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,10 @@ int orte_daemon(int argc, char *argv[])
933933
orte_finalize();
934934
opal_finalize_util();
935935

936+
orte_session_dir_cleanup(ORTE_JOBID_WILDCARD);
937+
/* cleanup the process info */
938+
orte_proc_info_finalize();
939+
936940
if (orte_debug_flag) {
937941
fprintf(stderr, "exiting with status %d\n", orte_exit_status);
938942
}

orte/runtime/orte_finalize.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
@@ -84,9 +84,6 @@ int orte_finalize(void)
8484
orte_schizo.finalize();
8585
(void) mca_base_framework_close(&orte_schizo_base_framework);
8686

87-
/* cleanup the process info */
88-
orte_proc_info_finalize();
89-
9087
/* Close the general debug stream */
9188
opal_output_close(orte_debug_output);
9289

orte/tools/orterun/orterun.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "orte/mca/rml/rml.h"
8787
#include "orte/mca/state/state.h"
8888
#include "orte/util/proc_info.h"
89+
#include "orte/util/session_dir.h"
8990
#include "orte/util/show_help.h"
9091
#include "orte/util/threads.h"
9192

@@ -222,6 +223,9 @@ int orterun(int argc, char *argv[])
222223
/* cleanup and leave */
223224
orte_submit_finalize();
224225
orte_finalize();
226+
orte_session_dir_cleanup(ORTE_JOBID_WILDCARD);
227+
/* cleanup the process info */
228+
orte_proc_info_finalize();
225229

226230
if (orte_debug_flag) {
227231
fprintf(stderr, "exiting with status %d\n", orte_exit_status);

orte/util/session_dir.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -370,45 +370,33 @@ int orte_session_dir(bool create, orte_process_name_t *proc)
370370
int
371371
orte_session_dir_cleanup(orte_jobid_t jobid)
372372
{
373-
int rc = ORTE_SUCCESS;
374-
375373
if (!orte_create_session_dirs || orte_process_info.rm_session_dirs ) {
376374
/* we haven't created them or RM will clean them up for us*/
377375
return ORTE_SUCCESS;
378376
}
379377

380-
if (NULL == orte_process_info.job_session_dir ||
378+
if (NULL == orte_process_info.jobfam_session_dir ||
381379
NULL == orte_process_info.proc_session_dir) {
382380
/* this should never happen - it means we are calling
383381
* cleanup *before* properly setting up the session
384382
* dir system. This leaves open the possibility of
385383
* accidentally removing directories we shouldn't
386384
* touch
387385
*/
388-
rc = ORTE_ERR_NOT_INITIALIZED;
389-
goto CLEANUP;
386+
return ORTE_ERR_NOT_INITIALIZED;
390387
}
391388

392389
/* recursively blow the whole session away for our job family,
393390
* saving only output files
394391
*/
395-
opal_os_dirpath_destroy(orte_process_info.job_session_dir,
392+
opal_os_dirpath_destroy(orte_process_info.jobfam_session_dir,
396393
true, orte_dir_check_file);
397394

398-
/* now attempt to eliminate the top level directory itself - this
399-
* will fail if anything is present, but ensures we cleanup if
400-
* we are the last one out
401-
*/
402-
if( NULL != orte_process_info.top_session_dir ){
403-
opal_os_dirpath_destroy(orte_process_info.top_session_dir,
404-
false, orte_dir_check_file);
405-
}
406-
407-
if (opal_os_dirpath_is_empty(orte_process_info.job_session_dir)) {
395+
if (opal_os_dirpath_is_empty(orte_process_info.jobfam_session_dir)) {
408396
if (orte_debug_flag) {
409-
opal_output(0, "sess_dir_cleanup: found job session dir empty - deleting");
397+
opal_output(0, "sess_dir_cleanup: found jobfam session dir empty - deleting");
410398
}
411-
rmdir(orte_process_info.job_session_dir);
399+
rmdir(orte_process_info.jobfam_session_dir);
412400
} else {
413401
if (orte_debug_flag) {
414402
if (OPAL_ERR_NOT_FOUND ==
@@ -418,12 +406,10 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
418406
opal_output(0, "sess_dir_cleanup: job session dir not empty - leaving");
419407
}
420408
}
421-
goto CLEANUP;
422409
}
423410

424-
if ( NULL != orte_process_info.top_session_dir ){
425-
426-
if( opal_os_dirpath_is_empty(orte_process_info.top_session_dir) ) {
411+
if (NULL != orte_process_info.top_session_dir) {
412+
if (opal_os_dirpath_is_empty(orte_process_info.top_session_dir)) {
427413
if (orte_debug_flag) {
428414
opal_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
429415
}
@@ -440,9 +426,17 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
440426
}
441427
}
442428

443-
CLEANUP:
429+
/* now attempt to eliminate the top level directory itself - this
430+
* will fail if anything is present, but ensures we cleanup if
431+
* we are the last one out
432+
*/
433+
if( NULL != orte_process_info.top_session_dir ){
434+
opal_os_dirpath_destroy(orte_process_info.top_session_dir,
435+
false, orte_dir_check_file);
436+
}
437+
444438

445-
return rc;
439+
return ORTE_SUCCESS;
446440
}
447441

448442

0 commit comments

Comments
 (0)