2005-03-14 23:57:21 +03:00
/*
2008-05-06 22:08:45 +04:00
* Copyright ( c ) 2004 - 2008 The Trustees of Indiana University and Indiana
2005-11-05 22:57:48 +03:00
* University Research and Technology
* Corporation . All rights reserved .
2006-08-23 07:32:36 +04:00
* Copyright ( c ) 2004 - 2006 The University of Tennessee and The University
2005-11-05 22:57:48 +03:00
* of Tennessee Research Foundation . All rights
* reserved .
2005-03-14 23:57:21 +03:00
* Copyright ( c ) 2004 - 2005 High Performance Computing Center Stuttgart ,
* University of Stuttgart . All rights reserved .
2005-03-24 15:43:37 +03:00
* Copyright ( c ) 2004 - 2005 The Regents of the University of California .
* All rights reserved .
2007-06-05 07:03:59 +04:00
* Copyright ( c ) 2007 Los Alamos National Security , LLC . All rights
* reserved .
2008-05-22 02:35:04 +04:00
* Copyright ( c ) 2008 Sun Microsystems , Inc . All rights reserved .
2005-03-14 23:57:21 +03:00
* $ COPYRIGHT $
*
* Additional copyrights may follow
*
* $ HEADER $
*
* These symbols are in a file by themselves to provide nice linker
* semantics . Since linkers generally pull in symbols by object
* files , keeping these symbols as the only symbols in this file
* prevents utility programs such as " ompi_info " from having to import
* entire components just to query their version and parameters .
*/
2006-02-12 04:33:29 +03:00
# include "orte_config.h"
2008-02-28 04:57:57 +03:00
# include "orte/constants.h"
2005-12-15 23:54:24 +03:00
2005-03-14 23:57:21 +03:00
# include <stdlib.h>
2005-06-22 02:48:57 +04:00
# ifdef HAVE_UNISTD_H
2005-03-14 23:57:21 +03:00
# include <unistd.h>
2005-06-22 02:48:57 +04:00
# endif
2005-12-15 23:54:24 +03:00
# include <ctype.h>
2005-03-14 23:57:21 +03:00
2007-06-05 07:03:59 +04:00
# include "opal/util/opal_environ.h"
2005-07-04 04:13:44 +04:00
# include "opal/util/argv.h"
2005-07-04 05:59:52 +04:00
# include "opal/util/path.h"
2005-07-04 04:13:44 +04:00
# include "opal/util/basename.h"
2006-02-12 04:33:29 +03:00
# include "opal/mca/base/mca_base_param.h"
2006-09-15 01:29:51 +04:00
# include "orte/mca/errmgr/errmgr.h"
2006-02-12 04:33:29 +03:00
# include "orte/mca/rml/rml.h"
2008-02-28 04:57:57 +03:00
# include "orte/util/name_fns.h"
2008-06-09 18:53:58 +04:00
# include "orte/util/show_help.h"
2005-03-14 23:57:21 +03:00
2008-02-28 04:57:57 +03:00
# include "orte/mca/plm/plm.h"
# include "orte/mca/plm/base/plm_private.h"
# include "orte/mca/plm/rsh/plm_rsh.h"
2006-09-15 01:29:51 +04:00
2005-12-15 23:54:24 +03:00
/*
* Local function
*/
static char * * search ( const char * agent_list ) ;
2005-03-14 23:57:21 +03:00
/*
2008-02-28 04:57:57 +03:00
* Public string showing the plm ompi_rsh component version number
2005-03-14 23:57:21 +03:00
*/
2008-02-28 04:57:57 +03:00
const char * mca_plm_rsh_component_version_string =
" Open MPI rsh plm MCA component version " ORTE_VERSION ;
2005-03-14 23:57:21 +03:00
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
2008-02-28 04:57:57 +03:00
orte_plm_rsh_component_t mca_plm_rsh_component = {
2005-03-14 23:57:21 +03:00
{
/* First, the mca_component_t struct containing meta information
about the component itself */
{
2008-07-29 02:40:57 +04:00
ORTE_PLM_BASE_VERSION_2_0_0 ,
2005-03-14 23:57:21 +03:00
/* Component name and version */
" rsh " ,
Major simplifications to component versioning:
- After long discussions and ruminations on how we run components in
LAM/MPI, made the decision that, by default, all components included
in Open MPI will use the version number of their parent project
(i.e., OMPI or ORTE). They are certaint free to use a different
number, but this simplification makes the common cases easy:
- components are only released when the parent project is released
- it is easy (trivial?) to distinguish which version component goes
with with version of the parent project
- removed all autogen/configure code for templating the version .h
file in components
- made all ORTE components use ORTE_*_VERSION for version numbers
- made all OMPI components use OMPI_*_VERSION for version numbers
- removed all VERSION files from components
- configure now displays OPAL, ORTE, and OMPI version numbers
- ditto for ompi_info
- right now, faking it -- OPAL and ORTE and OMPI will always have the
same version number (i.e., they all come from the same top-level
VERSION file). But this paves the way for the Great Configure
Reorganization, where, among other things, each project will have
its own version number.
So all in all, we went from a boatload of version numbers to
[effectively] three. That's pretty good. :-)
This commit was SVN r6344.
2005-07-05 00:12:36 +04:00
ORTE_MAJOR_VERSION ,
ORTE_MINOR_VERSION ,
ORTE_RELEASE_VERSION ,
2005-03-14 23:57:21 +03:00
/* Component open and close functions */
2008-02-28 04:57:57 +03:00
orte_plm_rsh_component_open ,
2008-05-06 22:08:45 +04:00
orte_plm_rsh_component_close ,
orte_plm_rsh_component_query
2005-03-14 23:57:21 +03:00
} ,
{
2007-03-17 02:11:45 +03:00
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
2008-05-06 22:08:45 +04:00
}
2005-03-14 23:57:21 +03:00
}
} ;
2008-02-28 04:57:57 +03:00
int orte_plm_rsh_component_open ( void )
2005-03-14 23:57:21 +03:00
{
2008-02-28 04:57:57 +03:00
int tmp ;
2008-05-06 22:08:45 +04:00
mca_base_component_t * c = & mca_plm_rsh_component . super . base_version ;
2005-04-14 18:08:21 +04:00
2005-03-14 23:57:21 +03:00
/* initialize globals */
2008-02-28 04:57:57 +03:00
OBJ_CONSTRUCT ( & mca_plm_rsh_component . lock , opal_mutex_t ) ;
OBJ_CONSTRUCT ( & mca_plm_rsh_component . cond , opal_condition_t ) ;
mca_plm_rsh_component . num_children = 0 ;
mca_plm_rsh_component . agent_argv = NULL ;
mca_plm_rsh_component . agent_argc = 0 ;
mca_plm_rsh_component . agent_path = NULL ;
2008-04-14 22:26:08 +04:00
OBJ_CONSTRUCT ( & mca_plm_rsh_component . children , opal_list_t ) ;
2005-03-14 23:57:21 +03:00
/* lookup parameters */
2005-08-04 19:09:02 +04:00
mca_base_param_reg_int ( c , " num_concurrent " ,
2008-02-28 04:57:57 +03:00
" How many plm_rsh_agent instances to invoke concurrently (must be > 0) " ,
2005-08-04 19:09:02 +04:00
false , false , 128 , & tmp ) ;
if ( tmp < = 0 ) {
This commit represents a bunch of work on a Mercurial side branch. As
such, the commit message back to the master SVN repository is fairly
long.
= ORTE Job-Level Output Messages =
Add two new interfaces that should be used for all new code throughout
the ORTE and OMPI layers (we already make the search-and-replace on
the existing ORTE / OMPI layers):
* orte_output(): (and corresponding friends ORTE_OUTPUT,
orte_output_verbose, etc.) This function sends the output directly
to the HNP for processing as part of a job-specific output
channel. It supports all the same outputs as opal_output()
(syslog, file, stdout, stderr), but for stdout/stderr, the output
is sent to the HNP for processing and output. More on this below.
* orte_show_help(): This function is a drop-in-replacement for
opal_show_help(), with two differences in functionality:
1. the rendered text help message output is sent to the HNP for
display (rather than outputting directly into the process' stderr
stream)
1. the HNP detects duplicate help messages and does not display them
(so that you don't see the same error message N times, once from
each of your N MPI processes); instead, it counts "new" instances
of the help message and displays a message every ~5 seconds when
there are new ones ("I got X new copies of the help message...")
opal_show_help and opal_output still exist, but they only output in
the current process. The intent for the new orte_* functions is that
they can apply job-level intelligence to the output. As such, we
recommend that all new ORTE and OMPI code use the new orte_*
functions, not thei opal_* functions.
=== New code ===
For ORTE and OMPI programmers, here's what you need to do differently
in new code:
* Do not include opal/util/show_help.h or opal/util/output.h.
Instead, include orte/util/output.h (this one header file has
declarations for both the orte_output() series of functions and
orte_show_help()).
* Effectively s/opal_output/orte_output/gi throughout your code.
Note that orte_output_open() takes a slightly different argument
list (as a way to pass data to the filtering stream -- see below),
so you if explicitly call opal_output_open(), you'll need to
slightly adapt to the new signature of orte_output_open().
* Literally s/opal_show_help/orte_show_help/. The function signature
is identical.
=== Notes ===
* orte_output'ing to stream 0 will do similar to what
opal_output'ing did, so leaving a hard-coded "0" as the first
argument is safe.
* For systems that do not use ORTE's RML or the HNP, the effect of
orte_output_* and orte_show_help will be identical to their opal
counterparts (the additional information passed to
orte_output_open() will be lost!). Indeed, the orte_* functions
simply become trivial wrappers to their opal_* counterparts. Note
that we have not tested this; the code is simple but it is quite
possible that we mucked something up.
= Filter Framework =
Messages sent view the new orte_* functions described above and
messages output via the IOF on the HNP will now optionally be passed
through a new "filter" framework before being output to
stdout/stderr. The "filter" OPAL MCA framework is intended to allow
preprocessing to messages before they are sent to their final
destinations. The first component that was written in the filter
framework was to create an XML stream, segregating all the messages
into different XML tags, etc. This will allow 3rd party tools to read
the stdout/stderr from the HNP and be able to know exactly what each
text message is (e.g., a help message, another OMPI infrastructure
message, stdout from the user process, stderr from the user process,
etc.).
Filtering is not active by default. Filter components must be
specifically requested, such as:
{{{
$ mpirun --mca filter xml ...
}}}
There can only be one filter component active.
= New MCA Parameters =
The new functionality described above introduces two new MCA
parameters:
* '''orte_base_help_aggregate''': Defaults to 1 (true), meaning that
help messages will be aggregated, as described above. If set to 0,
all help messages will be displayed, even if they are duplicates
(i.e., the original behavior).
* '''orte_base_show_output_recursions''': An MCA parameter to help
debug one of the known issues, described below. It is likely that
this MCA parameter will disappear before v1.3 final.
= Known Issues =
* The XML filter component is not complete. The current output from
this component is preliminary and not real XML. A bit more work
needs to be done to configure.m4 search for an appropriate XML
library/link it in/use it at run time.
* There are possible recursion loops in the orte_output() and
orte_show_help() functions -- e.g., if RML send calls orte_output()
or orte_show_help(). We have some ideas how to fix these, but
figured that it was ok to commit before feature freeze with known
issues. The code currently contains sub-optimal workarounds so
that this will not be a problem, but it would be good to actually
solve the problem rather than have hackish workarounds before v1.3 final.
This commit was SVN r18434.
2008-05-14 00:00:55 +04:00
orte_show_help ( " help-plm-rsh.txt " , " concurrency-less-than-zero " ,
2005-08-04 19:09:02 +04:00
true , tmp ) ;
tmp = 1 ;
}
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . num_concurrent = tmp ;
2006-09-08 19:17:17 +04:00
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
mca_base_param_reg_int ( c , " force_rsh " ,
2008-02-28 04:57:57 +03:00
" Force the launcher to always use rsh " ,
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
false , false , false , & tmp ) ;
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . force_rsh = OPAL_INT_TO_BOOL ( tmp ) ;
2008-05-22 02:35:04 +04:00
mca_base_param_reg_int ( c , " disable_qrsh " ,
" Disable the launcher to use qrsh when under the SGE parallel environment " ,
false , false , false , & tmp ) ;
mca_plm_rsh_component . disable_qrsh = OPAL_INT_TO_BOOL ( tmp ) ;
2006-10-11 19:18:57 +04:00
2005-08-04 19:09:02 +04:00
mca_base_param_reg_int ( c , " priority " ,
2008-02-28 04:57:57 +03:00
" Priority of the rsh plm component " ,
2005-08-04 19:09:02 +04:00
false , false , 10 ,
2008-02-28 04:57:57 +03:00
& mca_plm_rsh_component . priority ) ;
2005-08-04 19:09:02 +04:00
mca_base_param_reg_int ( c , " delay " ,
" Delay (in seconds) between invocations of the remote agent, but only used when the \" debug \" MCA parameter is true, or the top-level MCA debugging is enabled (otherwise this value is ignored) " ,
false , false , 1 ,
2008-02-28 04:57:57 +03:00
& mca_plm_rsh_component . delay ) ;
2005-08-04 19:09:02 +04:00
mca_base_param_reg_int ( c , " assume_same_shell " ,
2005-09-06 20:10:05 +04:00
" If set to 1, assume that the shell on the remote node is the same as the shell on the local node. Otherwise, probe for what the remote shell. " ,
2005-08-04 19:09:02 +04:00
false , false , 1 , & tmp ) ;
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . assume_same_shell = OPAL_INT_TO_BOOL ( tmp ) ;
2005-03-14 23:57:21 +03:00
2008-08-02 00:15:42 +04:00
tmp = mca_base_param_reg_string ( c , " agent " ,
2006-01-19 01:00:34 +03:00
" The command used to launch executables on remote nodes (typically either \" ssh \" or \" rsh \" ) " ,
2008-08-02 00:15:42 +04:00
false , false , " ssh : rsh " , NULL ) ;
mca_base_param_reg_syn_name ( tmp , " pls " , " rsh_agent " , true ) ;
mca_base_param_lookup_string ( tmp , & mca_plm_rsh_component . agent_param ) ;
2008-04-14 22:26:08 +04:00
mca_base_param_reg_int ( c , " tree_spawn " ,
" If set to 1, launch via a tree-based topology " ,
false , false , ( int ) false , & tmp ) ;
mca_plm_rsh_component . tree_spawn = OPAL_INT_TO_BOOL ( tmp ) ;
2005-12-22 17:37:19 +03:00
return ORTE_SUCCESS ;
}
2008-05-06 22:08:45 +04:00
int orte_plm_rsh_component_query ( mca_base_module_t * * module , int * priority )
2005-12-22 17:37:19 +03:00
{
char * bname ;
size_t i ;
2008-02-28 04:57:57 +03:00
/* Take the string that was given to us by the plm_rsh_agent MCA
2005-12-22 17:37:19 +03:00
param and search for it */
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . agent_argv =
search ( mca_plm_rsh_component . agent_param ) ;
mca_plm_rsh_component . agent_argc =
opal_argv_count ( mca_plm_rsh_component . agent_argv ) ;
mca_plm_rsh_component . agent_path = NULL ;
2008-05-22 02:35:04 +04:00
/* To be absolutely sure that we are under an SGE parallel env */
if ( ! mca_plm_rsh_component . disable_qrsh & &
NULL ! = getenv ( " SGE_ROOT " ) & & NULL ! = getenv ( " ARC " ) & &
NULL ! = getenv ( " PE_HOSTFILE " ) & & NULL ! = getenv ( " JOB_ID " ) ) {
/* setting exec_argv and exec_path for qrsh */
asprintf ( & mca_plm_rsh_component . agent_param , " qrsh " ) ;
asprintf ( & mca_plm_rsh_component . agent_path , " %s/bin/%s " , getenv ( " SGE_ROOT " ) , getenv ( " ARC " ) ) ;
asprintf ( & mca_plm_rsh_component . agent_argv [ 0 ] , " %s/bin/%s/qrsh " , getenv ( " SGE_ROOT " ) , getenv ( " ARC " ) ) ;
2008-06-09 18:53:58 +04:00
if ( 0 < opal_output_get_verbosity ( orte_plm_globals . output ) ) {
opal_output_verbose ( 1 , orte_plm_globals . output ,
2008-05-22 02:35:04 +04:00
" %s plm:rsh: using %s for launching \n " ,
ORTE_NAME_PRINT ( ORTE_PROC_MY_NAME ) ,
mca_plm_rsh_component . agent_argv [ 0 ] ) ;
}
}
2008-02-28 04:57:57 +03:00
if ( mca_plm_rsh_component . agent_argc > 0 ) {
2005-04-14 18:08:21 +04:00
/* If the agent is ssh, and debug was not selected, then
automatically add " -x " */
2008-02-28 04:57:57 +03:00
bname = opal_basename ( mca_plm_rsh_component . agent_argv [ 0 ] ) ;
if ( NULL ! = bname & & 0 = = strcmp ( bname , " ssh " )
2008-06-09 18:53:58 +04:00
& & 0 > = opal_output_get_verbosity ( orte_plm_globals . output ) ) {
2008-02-28 04:57:57 +03:00
for ( i = 1 ; NULL ! = mca_plm_rsh_component . agent_argv [ i ] ; + + i ) {
2005-12-22 17:37:19 +03:00
if ( 0 = = strcasecmp ( " -x " ,
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . agent_argv [ i ] ) ) {
2005-04-14 18:08:21 +04:00
break ;
}
}
2008-02-28 04:57:57 +03:00
if ( NULL = = mca_plm_rsh_component . agent_argv [ i ] ) {
opal_argv_append ( & mca_plm_rsh_component . agent_argc ,
& mca_plm_rsh_component . agent_argv , " -x " ) ;
2005-04-14 18:08:21 +04:00
}
}
2008-05-22 02:35:04 +04:00
/* If the agent is qrsh, then automatically add -inherit
* and grid engine PE related flags */
if ( NULL ! = bname & & 0 = = strcmp ( bname , " qrsh " ) ) {
opal_argv_append ( & mca_plm_rsh_component . agent_argc ,
& mca_plm_rsh_component . agent_argv , " -inherit " ) ;
/* Don't use the "-noshell" flag as qrsh would have a problem
* swallowing a long command */
opal_argv_append ( & mca_plm_rsh_component . agent_argc ,
& mca_plm_rsh_component . agent_argv , " -nostdin " ) ;
opal_argv_append ( & mca_plm_rsh_component . agent_argc ,
& mca_plm_rsh_component . agent_argv , " -V " ) ;
2008-06-09 18:53:58 +04:00
if ( 0 < opal_output_get_verbosity ( orte_plm_globals . output ) ) {
2008-05-22 02:35:04 +04:00
opal_argv_append ( & mca_plm_rsh_component . agent_argc ,
& mca_plm_rsh_component . agent_argv , " -verbose " ) ;
}
}
2005-04-14 18:08:21 +04:00
if ( NULL ! = bname ) {
free ( bname ) ;
}
2005-03-19 02:40:08 +03:00
}
2005-03-14 23:57:21 +03:00
2005-12-22 17:37:19 +03:00
/* If we didn't find the agent in the path, then don't use this
component */
2008-02-28 04:57:57 +03:00
if ( NULL = = mca_plm_rsh_component . agent_argv | |
NULL = = mca_plm_rsh_component . agent_argv [ 0 ] ) {
2008-06-09 18:53:58 +04:00
OPAL_OUTPUT_VERBOSE ( ( 1 , orte_plm_globals . output ,
2008-02-28 04:57:57 +03:00
" %s plm:rsh: unable to be used: cannot find the "
" launching agent. Looked for: %s \n " ,
ORTE_NAME_PRINT ( ORTE_PROC_MY_NAME ) ,
mca_plm_rsh_component . agent_param ) ) ;
2008-05-06 22:08:45 +04:00
* module = NULL ;
return ORTE_ERROR ;
2005-03-18 06:43:59 +03:00
}
2008-02-28 04:57:57 +03:00
mca_plm_rsh_component . agent_path =
opal_path_findv ( mca_plm_rsh_component . agent_argv [ 0 ] , X_OK ,
2005-12-22 17:37:19 +03:00
environ , NULL ) ;
2008-02-28 04:57:57 +03:00
if ( NULL = = mca_plm_rsh_component . agent_path ) {
2008-06-09 18:53:58 +04:00
OPAL_OUTPUT_VERBOSE ( ( 1 , orte_plm_globals . output ,
2008-02-28 04:57:57 +03:00
" %s plm:rsh: unable to be used: cannot find path "
" for launching agent \" %s \" \n " ,
ORTE_NAME_PRINT ( ORTE_PROC_MY_NAME ) ,
mca_plm_rsh_component . agent_argv [ 0 ] ) ) ;
2008-05-06 22:08:45 +04:00
* module = NULL ;
return ORTE_ERROR ;
2005-03-14 23:57:21 +03:00
}
2008-02-28 04:57:57 +03:00
* priority = mca_plm_rsh_component . priority ;
2008-05-06 22:08:45 +04:00
* module = ( mca_base_module_t * ) & orte_plm_rsh_module ;
return ORTE_SUCCESS ;
2005-03-14 23:57:21 +03:00
}
2008-02-28 04:57:57 +03:00
int orte_plm_rsh_component_close ( void )
2005-03-14 23:57:21 +03:00
{
2005-04-01 02:11:54 +04:00
/* cleanup state */
2008-02-28 04:57:57 +03:00
OBJ_DESTRUCT ( & mca_plm_rsh_component . lock ) ;
OBJ_DESTRUCT ( & mca_plm_rsh_component . cond ) ;
2008-04-14 22:26:08 +04:00
OBJ_DESTRUCT ( & mca_plm_rsh_component . children ) ;
2008-02-28 04:57:57 +03:00
if ( NULL ! = mca_plm_rsh_component . agent_param ) {
free ( mca_plm_rsh_component . agent_param ) ;
2005-12-22 17:37:19 +03:00
}
2008-02-28 04:57:57 +03:00
if ( NULL ! = mca_plm_rsh_component . agent_argv ) {
opal_argv_free ( mca_plm_rsh_component . agent_argv ) ;
2005-12-22 17:37:19 +03:00
}
2008-02-28 04:57:57 +03:00
if ( NULL ! = mca_plm_rsh_component . agent_path ) {
free ( mca_plm_rsh_component . agent_path ) ;
2005-12-22 17:37:19 +03:00
}
2005-03-14 23:57:21 +03:00
return ORTE_SUCCESS ;
}
2005-12-15 23:54:24 +03:00
/*
* Take a colon - delimited list of agents and locate the first one that
* we are able to find in the PATH . Split that one into argv and
* return it . If nothing found , then return NULL .
*/
static char * * search ( const char * agent_list )
{
int i , j ;
char * line , * * lines = opal_argv_split ( agent_list , ' : ' ) ;
char * * tokens , * tmp ;
char cwd [ PATH_MAX ] ;
getcwd ( cwd , PATH_MAX ) ;
for ( i = 0 ; NULL ! = lines [ i ] ; + + i ) {
line = lines [ i ] ;
/* Trim whitespace at the beginning and end of the line */
for ( j = 0 ; ' \0 ' ! = line [ j ] & & isspace ( line [ j ] ) ; + + line ) {
continue ;
}
for ( j = strlen ( line ) - 2 ; j > 0 & & isspace ( line [ j ] ) ; + + j ) {
line [ j ] = ' \0 ' ;
}
if ( strlen ( line ) < = 0 ) {
continue ;
}
/* Split it */
tokens = opal_argv_split ( line , ' ' ) ;
/* Look for the first token in the PATH */
tmp = opal_path_findv ( tokens [ 0 ] , X_OK , environ , cwd ) ;
if ( NULL ! = tmp ) {
2005-12-22 17:37:19 +03:00
free ( tokens [ 0 ] ) ;
tokens [ 0 ] = tmp ;
2005-12-15 23:54:24 +03:00
opal_argv_free ( lines ) ;
return tokens ;
}
/* Didn't find it */
opal_argv_free ( tokens ) ;
}
/* Doh -- didn't find anything */
opal_argv_free ( lines ) ;
return NULL ;
}