@@ -534,11 +534,8 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
534
534
535
535
static int setup_path (orte_app_context_t * app , char * * wdir )
536
536
{
537
- int rc ;
537
+ int rc = ORTE_SUCCESS ;
538
538
char dir [MAXPATHLEN ];
539
- char * * argvptr ;
540
- char * pathenv = NULL , * mpiexec_pathenv = NULL ;
541
- char * full_search ;
542
539
543
540
if (!orte_get_attribute (& app -> attributes , ORTE_APP_SSNDIR_CWD , NULL , OPAL_BOOL )) {
544
541
/* Try to change to the app's cwd and check that the app
@@ -572,40 +569,6 @@ static int setup_path(orte_app_context_t *app, char **wdir)
572
569
* wdir = NULL ;
573
570
}
574
571
575
- /* Search for the OMPI_exec_path and PATH settings in the environment. */
576
- for (argvptr = app -> env ; * argvptr != NULL ; argvptr ++ ) {
577
- if (0 == strncmp ("OMPI_exec_path=" , * argvptr , 15 )) {
578
- mpiexec_pathenv = * argvptr + 15 ;
579
- }
580
- if (0 == strncmp ("PATH=" , * argvptr , 5 )) {
581
- pathenv = * argvptr + 5 ;
582
- }
583
- }
584
-
585
- /* If OMPI_exec_path is set (meaning --path was used), then create a
586
- temporary environment to be used in the search for the executable.
587
- The PATH setting in this temporary environment is a combination of
588
- the OMPI_exec_path and PATH values. If OMPI_exec_path is not set,
589
- then just use existing environment with PATH in it. */
590
- if (NULL != mpiexec_pathenv ) {
591
- argvptr = NULL ;
592
- if (pathenv != NULL ) {
593
- asprintf (& full_search , "%s:%s" , mpiexec_pathenv , pathenv );
594
- } else {
595
- asprintf (& full_search , "%s" , mpiexec_pathenv );
596
- }
597
- opal_setenv ("PATH" , full_search , true, & argvptr );
598
- free (full_search );
599
- } else {
600
- argvptr = app -> env ;
601
- }
602
-
603
- rc = orte_util_check_context_app (app , argvptr );
604
- /* do not ERROR_LOG - it will be reported elsewhere */
605
- if (NULL != mpiexec_pathenv ) {
606
- opal_argv_free (argvptr );
607
- }
608
-
609
572
CLEANUP :
610
573
return rc ;
611
574
}
@@ -662,6 +625,9 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata)
662
625
int rc , i ;
663
626
bool found ;
664
627
orte_proc_state_t state ;
628
+ char * * argvptr ;
629
+ char * pathenv = NULL , * mpiexec_pathenv = NULL ;
630
+ char * full_search ;
665
631
666
632
/* thread-protect common values */
667
633
cd -> env = opal_argv_copy (app -> env );
@@ -762,6 +728,44 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata)
762
728
goto errorout ;
763
729
}
764
730
731
+ /* Search for the OMPI_exec_path and PATH settings in the environment. */
732
+ for (argvptr = app -> env ; * argvptr != NULL ; argvptr ++ ) {
733
+ if (0 == strncmp ("OMPI_exec_path=" , * argvptr , 15 )) {
734
+ mpiexec_pathenv = * argvptr + 15 ;
735
+ }
736
+ if (0 == strncmp ("PATH=" , * argvptr , 5 )) {
737
+ pathenv = * argvptr + 5 ;
738
+ }
739
+ }
740
+
741
+ /* If OMPI_exec_path is set (meaning --path was used), then create a
742
+ temporary environment to be used in the search for the executable.
743
+ The PATH setting in this temporary environment is a combination of
744
+ the OMPI_exec_path and PATH values. If OMPI_exec_path is not set,
745
+ then just use existing environment with PATH in it. */
746
+ if (NULL != mpiexec_pathenv ) {
747
+ argvptr = NULL ;
748
+ if (pathenv != NULL ) {
749
+ asprintf (& full_search , "%s:%s" , mpiexec_pathenv , pathenv );
750
+ } else {
751
+ asprintf (& full_search , "%s" , mpiexec_pathenv );
752
+ }
753
+ opal_setenv ("PATH" , full_search , true, & argvptr );
754
+ free (full_search );
755
+ } else {
756
+ argvptr = app -> env ;
757
+ }
758
+
759
+ rc = orte_util_check_context_app (app , argvptr );
760
+ /* do not ERROR_LOG - it will be reported elsewhere */
761
+ if (NULL != mpiexec_pathenv ) {
762
+ opal_argv_free (argvptr );
763
+ }
764
+ if (ORTE_SUCCESS != rc ) {
765
+ state = ORTE_PROC_STATE_FAILED_TO_LAUNCH ;
766
+ goto errorout ;
767
+ }
768
+
765
769
/* if we are indexing the argv by rank, do so now */
766
770
if (cd -> index_argv && !ORTE_FLAG_TEST (jobdat , ORTE_JOB_FLAG_DEBUGGER_DAEMON )) {
767
771
char * param ;
0 commit comments