1515 * Copyright (c) 2010 IBM Corporation. All rights reserved.
1616 * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
1717 * reserved.
18- * Copyright (c) 2013-2016 Intel, Inc. All rights reserved
18+ * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
1919 *
2020 * $COPYRIGHT$
2121 *
@@ -144,8 +144,9 @@ static int orte_odls_default_restart_proc(orte_proc_t *child);
144144static void send_error_show_help (int fd , int exit_status ,
145145 const char * file , const char * topic , ...)
146146 __opal_attribute_noreturn__ ;
147- static int do_child (orte_app_context_t * context ,
148- orte_proc_t * child ,
147+
148+ static int do_child (orte_proc_t * child ,
149+ char * cmd , char * * argv ,
149150 char * * environ_copy ,
150151 orte_job_t * jobdat , int write_fd ,
151152 orte_iof_base_io_conf_t opts )
@@ -318,16 +319,15 @@ static int close_open_file_descriptors(int write_fd,
318319 return ORTE_SUCCESS ;
319320}
320321
321- static int do_child (orte_app_context_t * context ,
322- orte_proc_t * child ,
322+ static int do_child (orte_proc_t * child ,
323+ char * app , char * * argv ,
323324 char * * environ_copy ,
324325 orte_job_t * jobdat , int write_fd ,
325326 orte_iof_base_io_conf_t opts )
326327{
327- int i , rc ;
328+ int i ;
328329 sigset_t sigs ;
329330 long fd , fdmax = sysconf (_SC_OPEN_MAX );
330- char * param , * msg ;
331331
332332#if HAVE_SETPGID
333333 /* Set a new process group for this child, so that any
@@ -359,7 +359,7 @@ static int do_child(orte_app_context_t* context,
359359 send_error_show_help (write_fd , 1 ,
360360 "help-orte-odls-default.txt" ,
361361 "iof setup failed" ,
362- orte_process_info .nodename , context -> app );
362+ orte_process_info .nodename , app );
363363 /* Does not return */
364364 }
365365 }
@@ -384,18 +384,6 @@ static int do_child(orte_app_context_t* context,
384384 close (fdnull );
385385 }
386386
387- /* if the user requested it, set the system resource limits */
388- if (OPAL_SUCCESS != (rc = opal_util_init_sys_limits (& msg ))) {
389- send_error_show_help (write_fd , 1 , "help-orte-odls-default.txt" ,
390- "set limit" ,
391- orte_process_info .nodename , context -> app ,
392- __FILE__ , __LINE__ , msg );
393- }
394- /* ensure we only do this once */
395- (void ) mca_base_var_env_name ("opal_set_max_sys_limits" , & param );
396- opal_unsetenv (param , & environ_copy );
397- free (param );
398-
399387 /* close all open file descriptors w/ exception of stdin/stdout/stderr,
400388 the pipe used for the IOF INTERNAL messages, and the pipe up to
401389 the parent. */
@@ -408,10 +396,10 @@ static int do_child(orte_app_context_t* context,
408396 }
409397 }
410398
411- if (context -> argv == NULL ) {
412- context -> argv = malloc (sizeof (char * )* 2 );
413- context -> argv [0 ] = strdup (context -> app );
414- context -> argv [1 ] = NULL ;
399+ if (argv == NULL ) {
400+ argv = malloc (sizeof (char * )* 2 );
401+ argv [0 ] = strdup (app );
402+ argv [1 ] = NULL ;
415403 }
416404
417405 /* Set signal handlers back to the default. Do this close to
@@ -436,16 +424,16 @@ static int do_child(orte_app_context_t* context,
436424
437425 /* Exec the new executable */
438426
439- execve (context -> app , context -> argv , environ_copy );
427+ execve (app , argv , environ_copy );
440428 send_error_show_help (write_fd , 1 ,
441429 "help-orte-odls-default.txt" , "execve error" ,
442- orte_process_info .nodename , context -> app , strerror (errno ));
430+ orte_process_info .nodename , app , strerror (errno ));
443431 /* Does not return */
444432}
445433
446434
447- static int do_parent (orte_app_context_t * context ,
448- orte_proc_t * child ,
435+ static int do_parent (orte_proc_t * child ,
436+ char * app , char * * argv ,
449437 char * * environ_copy ,
450438 orte_job_t * jobdat , int read_fd ,
451439 orte_iof_base_io_conf_t opts )
@@ -454,19 +442,10 @@ static int do_parent(orte_app_context_t* context,
454442 orte_odls_pipe_err_msg_t msg ;
455443 char file [ORTE_ODLS_MAX_FILE_LEN + 1 ], topic [ORTE_ODLS_MAX_TOPIC_LEN + 1 ], * str = NULL ;
456444
457- if (NULL != child && ORTE_FLAG_TEST (jobdat , ORTE_JOB_FLAG_FORWARD_OUTPUT )) {
458- /* connect endpoints IOF */
459- rc = orte_iof_base_setup_parent (& child -> name , & opts );
460- if (ORTE_SUCCESS != rc ) {
461- ORTE_ERROR_LOG (rc );
462- close (read_fd );
463-
464- if (NULL != child ) {
465- child -> state = ORTE_PROC_STATE_UNDEF ;
466- }
467- return rc ;
468- }
469- }
445+ close (opts .p_stdin [0 ]);
446+ close (opts .p_stdout [1 ]);
447+ close (opts .p_stderr [1 ]);
448+ close (opts .p_internal [1 ]);
470449
471450 /* Block reading a message from the pipe */
472451 while (1 ) {
@@ -503,7 +482,7 @@ static int do_parent(orte_app_context_t* context,
503482 if (OPAL_SUCCESS != rc ) {
504483 orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
505484 true,
506- orte_process_info .nodename , context -> app ,
485+ orte_process_info .nodename , app ,
507486 "opal_fd_read" , __FILE__ , __LINE__ );
508487 if (NULL != child ) {
509488 child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -517,7 +496,7 @@ static int do_parent(orte_app_context_t* context,
517496 if (OPAL_SUCCESS != rc ) {
518497 orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
519498 true,
520- orte_process_info .nodename , context -> app ,
499+ orte_process_info .nodename , app ,
521500 "opal_fd_read" , __FILE__ , __LINE__ );
522501 if (NULL != child ) {
523502 child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -531,7 +510,7 @@ static int do_parent(orte_app_context_t* context,
531510 if (NULL == str ) {
532511 orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
533512 true,
534- orte_process_info .nodename , context -> app ,
513+ orte_process_info .nodename , app ,
535514 "opal_fd_read" , __FILE__ , __LINE__ );
536515 if (NULL != child ) {
537516 child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -580,39 +559,16 @@ static int do_parent(orte_app_context_t* context,
580559/**
581560 * Fork/exec the specified processes
582561 */
583- static int odls_default_fork_local_proc (orte_app_context_t * context ,
584- orte_proc_t * child ,
562+ static int odls_default_fork_local_proc (orte_proc_t * child ,
563+ char * app ,
564+ char * * argv ,
585565 char * * environ_copy ,
586- orte_job_t * jobdat )
566+ orte_job_t * jobdat ,
567+ orte_iof_base_io_conf_t opts )
587568{
588- orte_iof_base_io_conf_t opts = {0 };
589- int rc , p [2 ];
569+ int p [2 ];
590570 pid_t pid ;
591571
592- if (NULL != child ) {
593- /* should pull this information from MPIRUN instead of going with
594- default */
595- opts .usepty = OPAL_ENABLE_PTY_SUPPORT ;
596-
597- /* do we want to setup stdin? */
598- if (NULL != child &&
599- (jobdat -> stdin_target == ORTE_VPID_WILDCARD ||
600- child -> name .vpid == jobdat -> stdin_target )) {
601- opts .connect_stdin = true;
602- } else {
603- opts .connect_stdin = false;
604- }
605-
606- if (ORTE_SUCCESS != (rc = orte_iof_base_setup_prefork (& opts ))) {
607- ORTE_ERROR_LOG (rc );
608- if (NULL != child ) {
609- child -> state = ORTE_PROC_STATE_FAILED_TO_START ;
610- child -> exit_code = rc ;
611- }
612- return rc ;
613- }
614- }
615-
616572 /* A pipe is used to communicate between the parent and child to
617573 indicate whether the exec ultimately succeeded or failed. The
618574 child sets the pipe to be close-on-exec; the child only ever
@@ -647,12 +603,12 @@ static int odls_default_fork_local_proc(orte_app_context_t* context,
647603
648604 if (pid == 0 ) {
649605 close (p [0 ]);
650- do_child (context , child , environ_copy , jobdat , p [1 ], opts );
606+ do_child (child , app , argv , environ_copy , jobdat , p [1 ], opts );
651607 /* Does not return */
652608 }
653609
654610 close (p [1 ]);
655- return do_parent (context , child , environ_copy , jobdat , p [0 ], opts );
611+ return do_parent (child , app , argv , environ_copy , jobdat , p [0 ], opts );
656612}
657613
658614
0 commit comments