From ef20da3d122471e0ffb7ac184ccb278e8e3c777e Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Thu, 14 Apr 2005 21:08:36 +0000 Subject: [PATCH] cleanup environment This commit was SVN r5362. --- src/mca/pls/fork/pls_fork_component.c | 8 +++++++- src/mca/pls/fork/pls_fork_module.c | 29 ++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/mca/pls/fork/pls_fork_component.c b/src/mca/pls/fork/pls_fork_component.c index 80b8bc7f7a..8e853ce4f9 100644 --- a/src/mca/pls/fork/pls_fork_component.c +++ b/src/mca/pls/fork/pls_fork_component.c @@ -107,9 +107,15 @@ int orte_pls_fork_component_open(void) OBJ_CONSTRUCT(&mca_pls_fork_component.cond, ompi_condition_t); /* lookup parameters */ - mca_pls_fork_component.debug = orte_pls_fork_param_register_int("debug",1); mca_pls_fork_component.reap = orte_pls_fork_param_register_int("reap",1); mca_pls_fork_component.priority = orte_pls_fork_param_register_int("priority",1); + mca_pls_fork_component.debug = orte_pls_fork_param_register_int("debug",0); + if(mca_pls_fork_component.debug == 0) { + int id = mca_base_param_register_int("debug",NULL,NULL,NULL,0); + int value; + mca_base_param_lookup_int(id,&value); + mca_pls_fork_component.debug = (value > 0) ? 1 : 0; + } return ORTE_SUCCESS; } diff --git a/src/mca/pls/fork/pls_fork_module.c b/src/mca/pls/fork/pls_fork_module.c index 7e2903e686..f972705b03 100644 --- a/src/mca/pls/fork/pls_fork_module.c +++ b/src/mca/pls/fork/pls_fork_module.c @@ -135,6 +135,11 @@ static int orte_pls_fork_proc( ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); } + /* setup base environment */ + environ_copy = ompi_argv_copy(environ); + param = mca_base_param_environ_variable("rmgr","bootproxy","jobid"); + ompi_unsetenv(param, &environ_copy); + /* setup ns contact info */ if(NULL != orte_process_info.ns_replica_uri) { uri = strdup(orte_process_info.ns_replica_uri); @@ -142,7 +147,7 @@ static int orte_pls_fork_proc( uri = orte_rml.get_uri(); } param = mca_base_param_environ_variable("ns","replica","uri"); - ompi_setenv(param, uri, true, &environ); + ompi_setenv(param, uri, true, &environ_copy); free(param); free(uri); @@ -153,12 +158,11 @@ static int orte_pls_fork_proc( uri = orte_rml.get_uri(); } param = mca_base_param_environ_variable("gpr","replica","uri"); - ompi_setenv(param, uri, true, &environ); + ompi_setenv(param, uri, true, &environ_copy); free(param); free(uri); /* push name into environment */ - environ_copy = ompi_argv_copy(environ); orte_ns_nds_env_put(&proc->proc_name, vpid_start, vpid_range, &environ_copy); @@ -177,6 +181,12 @@ static int orte_pls_fork_proc( /* execute application */ new_env = ompi_environ_merge(context->env, environ_copy); ompi_argv_free(environ_copy); + + if(context->argv == NULL) { + context->argv = malloc(sizeof(char*)*2); + context->argv[0] = strdup(context->app); + context->argv[1] = NULL; + } execve(context->app, context->argv, new_env); ompi_output(0, "orte_pls_fork: %s - %s\n", context->app, ompi_argv_join(context->argv, ' ')); @@ -185,6 +195,13 @@ static int orte_pls_fork_proc( } else { + /* wait for the child process */ + OMPI_THREAD_LOCK(&mca_pls_fork_component.lock); + mca_pls_fork_component.num_children++; + OMPI_THREAD_UNLOCK(&mca_pls_fork_component.lock); + OBJ_RETAIN(proc); + orte_wait_cb(pid, orte_pls_fork_wait_proc, proc); + /* close write end of pipes */ close(p_stdout[1]); close(p_stderr[1]); @@ -208,12 +225,6 @@ static int orte_pls_fork_proc( return rc; } - /* wait for the child process */ - OMPI_THREAD_LOCK(&mca_pls_fork_component.lock); - mca_pls_fork_component.num_children++; - OMPI_THREAD_UNLOCK(&mca_pls_fork_component.lock); - OBJ_RETAIN(proc); - orte_wait_cb(pid, orte_pls_fork_wait_proc, proc); } return ORTE_SUCCESS; }