Commit 30f350ea authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r6975] Added code to disable auto-cleanup of processes when requested by the

user.
parent ea6cd7ba
......@@ -312,6 +312,8 @@ struct HYD_user_global {
int enablex;
int debug;
int auto_cleanup;
struct HYD_env_global global_env;
};
......
......@@ -273,15 +273,20 @@ static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp)
}
if (closed) {
/* This is a hack to improve user-friendliness. If a PMI
* application terminates, we clean up the remaining
/* If a PMI application terminates, we clean up the remaining
* processes. For a correct PMI application, we should never
* get closed socket event as we deregister this socket as
* soon as we get the finalize message. For non-PMI
* applications, this is harder to identify, so we just let
* the user cleanup the processes on a failure. */
if (using_pmi_port || HYD_pmcd_pmip.downstream.pmi_fd_active[i])
HYD_pmcd_pmip_killjob();
if (using_pmi_port || HYD_pmcd_pmip.downstream.pmi_fd_active[i]) {
if (HYD_pmcd_pmip.user_global.auto_cleanup)
HYD_pmcd_pmip_killjob();
else {
/* If the user doesn't want to automatically cleanup,
* just deregister the FD and ignore this error */
}
}
goto fn_exit;
}
......
......@@ -98,6 +98,11 @@ static HYD_status enable_stdin_fn(char *arg, char ***argv)
return HYDU_set_int_and_incr(arg, argv, &HYD_pmcd_pmip.system_global.enable_stdin);
}
static HYD_status auto_cleanup_fn(char *arg, char ***argv)
{
return HYDU_set_int_and_incr(arg, argv, &HYD_pmcd_pmip.user_global.auto_cleanup);
}
static HYD_status pmi_port_fn(char *arg, char ***argv)
{
return HYDU_set_str_and_incr(arg, argv, &HYD_pmcd_pmip.system_global.pmi_port);
......@@ -393,6 +398,7 @@ struct HYD_arg_match_table HYD_pmcd_pmip_match_table[] = {
{"iface", iface_fn, NULL},
{"prepend-rank", prepend_rank_fn, NULL},
{"enable-stdin", enable_stdin_fn, NULL},
{"auto-cleanup", auto_cleanup_fn, NULL},
/* Executable parameters */
{"pmi-port", pmi_port_fn, NULL},
......
......@@ -167,6 +167,8 @@ HYD_status HYD_pmcd_pmi_fill_in_exec_launch_info(struct HYD_pg *pg)
proxy->exec_launch_info[arg++] = HYDU_strdup("--global-process-count");
proxy->exec_launch_info[arg++] = HYDU_int_to_str(pg->pg_process_count);
proxy->exec_launch_info[arg++] = HYDU_strdup("--auto-cleanup");
proxy->exec_launch_info[arg++] = HYDU_int_to_str(HYD_handle.user_global.auto_cleanup);
/* Check if we are running in embedded mode */
ret = MPL_env2str("PMI_FD", (const char **) &pmi_fd);
......
......@@ -105,6 +105,7 @@ static void usage(void)
printf(" -prepend-rank prepend rank to output\n");
printf
(" -nameserver name server information (host:port format)\n");
printf(" -disable-auto-cleanup don't cleanup processes on error\n");
}
static void signal_cb(int sig)
......
......@@ -840,6 +840,19 @@ static HYD_status nameserver_fn(char *arg, char ***argv)
return HYDU_set_str_and_incr(arg, argv, &HYD_handle.nameserver);
}
static void auto_cleanup_help_fn(void)
{
printf("\n");
printf("-disable-auto-cleanup: Don't auto-cleanup of processes when the app aborts\n");
printf("-enable-auto-cleanup: Auto-cleanup processes when the app aborts (default)\n\n");
}
static HYD_status auto_cleanup_fn(char *arg, char ***argv)
{
return HYDU_set_int(arg, argv, &HYD_handle.user_global.auto_cleanup,
!strcmp(arg, "enable-auto-cleanup"));
}
static struct HYD_arg_match_table match_table[] = {
/* Global environment options */
{"genv", genv_fn, genv_help_fn},
......@@ -910,6 +923,8 @@ static struct HYD_arg_match_table match_table[] = {
{"print-all-exitcodes", print_all_exitcodes_fn, print_all_exitcodes_help_fn},
{"iface", iface_fn, iface_help_fn},
{"nameserver", nameserver_fn, nameserver_help_fn},
{"disable-auto-cleanup", auto_cleanup_fn, auto_cleanup_help_fn},
{"enable-auto-cleanup", auto_cleanup_fn, auto_cleanup_help_fn},
{"\0", NULL}
};
......@@ -961,6 +976,9 @@ static HYD_status set_default_values(void)
HYD_handle.user_global.global_env.prop =
!strcmp(tmp, "all") ? HYDU_strdup("all") : HYDU_strdup("none");
if (HYD_handle.user_global.auto_cleanup == -1)
HYD_handle.user_global.auto_cleanup = 1;
fn_exit:
return status;
......
......@@ -24,6 +24,8 @@ void HYDU_init_user_global(struct HYD_user_global *user_global)
user_global->debug = -1;
user_global->prepend_rank = -1;
user_global->auto_cleanup = -1;
HYDU_init_global_env(&user_global->global_env);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment