Fix the use of --path and -x PATH so that things work properly.
Note that --path specifies extra directories where the executable is searched for, but does not affect the PATH settings. This commit fixes trac:1221. This commit was SVN r17748. The following Trac tickets were found above: Ticket 1221 --> https://svn.open-mpi.org/trac/ompi/ticket/1221
Этот коммит содержится в:
родитель
91af56db00
Коммит
03fdd57d5a
@ -9,7 +9,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -635,6 +635,9 @@ static int odls_base_default_setup_fork(orte_app_context_t *context,
|
||||
int rc;
|
||||
int i;
|
||||
char *param, *param2;
|
||||
char *full_search;
|
||||
char *pathenv = NULL, *mpiexec_pathenv = NULL;
|
||||
char **argvptr;
|
||||
|
||||
/* check the system limits - if we are at our max allowed children, then
|
||||
* we won't be allowed to do this anyway, so we may as well abort now.
|
||||
@ -649,7 +652,15 @@ static int odls_base_default_setup_fork(orte_app_context_t *context,
|
||||
return ORTE_ERR_SYS_LIMITS_CHILDREN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* setup base environment: copy the current environ and merge
|
||||
in the app context environ */
|
||||
if (NULL != context->env) {
|
||||
*environ_copy = opal_environ_merge(orte_launch_environ, context->env);
|
||||
} else {
|
||||
*environ_copy = opal_argv_copy(orte_launch_environ);
|
||||
}
|
||||
|
||||
/* Try to change to the context cwd and check that the app
|
||||
exists and is executable The function will
|
||||
take care of outputting a pretty error message, if required
|
||||
@ -658,17 +669,44 @@ static int odls_base_default_setup_fork(orte_app_context_t *context,
|
||||
/* do not ERROR_LOG - it will be reported elsewhere */
|
||||
return rc;
|
||||
}
|
||||
if (ORTE_SUCCESS != (rc = orte_util_check_context_app(context))) {
|
||||
|
||||
/* Search for the OMPI_exec_path and PATH settings in the environment. */
|
||||
for (argvptr = *environ_copy; *argvptr != NULL; argvptr++) {
|
||||
if (0 == strncmp("OMPI_exec_path=", *argvptr, 15)) {
|
||||
mpiexec_pathenv = *argvptr + 15;
|
||||
}
|
||||
if (0 == strncmp("PATH=", *argvptr, 5)) {
|
||||
pathenv = *argvptr + 5;
|
||||
}
|
||||
}
|
||||
|
||||
/* If OMPI_exec_path is set (meaning --path was used), then create a
|
||||
temporary environment to be used in the search for the executable.
|
||||
The PATH setting in this temporary environment is a combination of
|
||||
the OMPI_exec_path and PATH values. If OMPI_exec_path is not set,
|
||||
then just use existing environment with PATH in it. */
|
||||
if (mpiexec_pathenv) {
|
||||
argvptr = NULL;
|
||||
if (pathenv != NULL) {
|
||||
asprintf(&full_search, "%s:%s", mpiexec_pathenv, pathenv);
|
||||
} else {
|
||||
asprintf(&full_search, "%s", mpiexec_pathenv);
|
||||
}
|
||||
opal_setenv("PATH", full_search, true, &argvptr);
|
||||
free(full_search);
|
||||
} else {
|
||||
argvptr = *environ_copy;
|
||||
}
|
||||
|
||||
if (ORTE_SUCCESS != (rc = orte_util_check_context_app(context, argvptr))) {
|
||||
/* do not ERROR_LOG - it will be reported elsewhere */
|
||||
if (mpiexec_pathenv) {
|
||||
opal_argv_free(argvptr);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* setup base environment: copy the current environ and merge
|
||||
in the app context environ */
|
||||
if (NULL != context->env) {
|
||||
*environ_copy = opal_environ_merge(orte_launch_environ, context->env);
|
||||
} else {
|
||||
*environ_copy = opal_argv_copy(orte_launch_environ);
|
||||
if (mpiexec_pathenv) {
|
||||
opal_argv_free(argvptr);
|
||||
}
|
||||
|
||||
/* special case handling for --prefix: this is somewhat icky,
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
@ -1556,10 +1556,10 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
/* Did the user request a specific path? */
|
||||
|
||||
/* If the user specified --path, store it in the user's app
|
||||
environment via the OMPI_exec_path variable. */
|
||||
if (NULL != orterun_globals.path) {
|
||||
asprintf(&value, "PATH=%s", orterun_globals.path);
|
||||
asprintf(&value, "OMPI_exec_path=%s", orterun_globals.path);
|
||||
opal_argv_append_nosize(&app->env, value);
|
||||
free(value);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -114,13 +115,9 @@ int orte_util_check_context_cwd(orte_app_context_t *context,
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
int orte_util_check_context_app(orte_app_context_t *context)
|
||||
int orte_util_check_context_app(orte_app_context_t *context, char **env)
|
||||
{
|
||||
char *tmp;
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
|
||||
/* Use hostname in a few messages below */
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
/* If the app is a naked filename, we need to do a path search for
|
||||
it. orterun will send in whatever the user specified (e.g.,
|
||||
@ -147,7 +144,7 @@ int orte_util_check_context_app(orte_app_context_t *context)
|
||||
/* If this is a naked executable -- no relative or absolute
|
||||
pathname -- then search the PATH for it */
|
||||
free(tmp);
|
||||
tmp = opal_path_findv(context->argv[0], X_OK, environ, context->cwd);
|
||||
tmp = opal_path_findv(context->argv[0], X_OK, env, context->cwd);
|
||||
if (NULL == tmp) {
|
||||
return ORTE_ERR_EXE_NOT_FOUND;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -30,7 +31,8 @@
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
ORTE_DECLSPEC int orte_util_check_context_app(orte_app_context_t *context);
|
||||
ORTE_DECLSPEC int orte_util_check_context_app(orte_app_context_t *context,
|
||||
char **env);
|
||||
|
||||
ORTE_DECLSPEC int orte_util_check_context_cwd(orte_app_context_t *context,
|
||||
bool want_chdir);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user