1212 * All rights reserved.
1313 * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1414 * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
15- * Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
15+ * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
1616 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1717 * reserved.
18+ * Copyright (c) 2016 Research Organization for Information Science
19+ * and Technology (RIST). All rights reserved.
1820 * $COPYRIGHT$
1921 *
2022 * Additional copyrights may follow
@@ -74,7 +76,6 @@ static bool added_transport_keys=false;
7476static bool added_num_procs = false;
7577static bool added_app_ctx = false;
7678static bool added_pmix_envs = false;
77- static char * pmixenvars [4 ];
7879static bool progress_thread_running = false;
7980
8081static int fork_hnp (void );
@@ -83,9 +84,9 @@ static int rte_init(void)
8384{
8485 int rc , ret ;
8586 char * error = NULL ;
86- char * envar , * ev1 , * ev2 ;
8787 uint64_t unique_key [2 ];
8888 char * string_key ;
89+ char * envar ;
8990 opal_value_t * kv ;
9091 char * val ;
9192 int u32 , * u32ptr ;
@@ -225,13 +226,17 @@ static int rte_init(void)
225226 * MPI-3 required info key
226227 */
227228 if (NULL == getenv (OPAL_MCA_PREFIX "orte_ess_num_procs" )) {
228- asprintf (& ev1 , OPAL_MCA_PREFIX "orte_ess_num_procs=%d" , orte_process_info .num_procs );
229- putenv (ev1 );
229+ char * num_procs ;
230+ asprintf (& num_procs , "%d" , orte_process_info .num_procs );
231+ opal_setenv (OPAL_MCA_PREFIX "orte_ess_num_procs" , num_procs , true, & environ );
232+ free (num_procs );
230233 added_num_procs = true;
231234 }
232235 if (NULL == getenv ("OMPI_APP_CTX_NUM_PROCS" )) {
233- asprintf (& ev2 , "OMPI_APP_CTX_NUM_PROCS=%d" , orte_process_info .num_procs );
234- putenv (ev2 );
236+ char * num_procs ;
237+ asprintf (& num_procs , "%d" , orte_process_info .num_procs );
238+ opal_setenv ("OMPI_APP_CTX_NUM_PROCS" , num_procs , true, & environ );
239+ free (num_procs );
235240 added_app_ctx = true;
236241 }
237242
@@ -546,6 +551,8 @@ static int fork_hnp(void)
546551 exit (1 );
547552
548553 } else {
554+ int count ;
555+
549556 free (cmd );
550557 /* I am the parent - wait to hear something back and
551558 * report results
@@ -612,14 +619,13 @@ static int fork_hnp(void)
612619
613620 /* split the pmix_uri into its parts */
614621 argv = opal_argv_split (cptr , ',' );
615- if (4 != opal_argv_count (argv )) {
616- opal_argv_free (argv );
617- return ORTE_ERR_BAD_PARAM ;
618- }
622+ count = opal_argv_count (argv );
619623 /* push each piece into the environment */
620- for (i = 0 ; i < 4 ; i ++ ) {
621- pmixenvars [i ] = strdup (argv [i ]);
622- putenv (pmixenvars [i ]);
624+ for (i = 0 ; i < count ; i ++ ) {
625+ char * c = strchr (argv [i ], '=' );
626+ assert (NULL != c );
627+ * c ++ = '\0' ;
628+ opal_setenv (argv [i ], c , true, & environ );
623629 }
624630 opal_argv_free (argv );
625631 added_pmix_envs = true;
0 commit comments