15
15
* Copyright (c) 2010 IBM Corporation. All rights reserved.
16
16
* Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights
17
17
* reserved.
18
- * Copyright (c) 2013-2016 Intel, Inc. All rights reserved
18
+ * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
19
19
*
20
20
* $COPYRIGHT$
21
21
*
@@ -144,8 +144,8 @@ static int orte_odls_alps_restart_proc(orte_proc_t *child);
144
144
static void send_error_show_help (int fd , int exit_status ,
145
145
const char * file , const char * topic , ...)
146
146
__opal_attribute_noreturn__ ;
147
- static int do_child (orte_app_context_t * context ,
148
- orte_proc_t * child ,
147
+ static int do_child (orte_proc_t * child ,
148
+ char * app , char * * argv ,
149
149
char * * environ_copy ,
150
150
orte_job_t * jobdat , int write_fd ,
151
151
orte_iof_base_io_conf_t opts )
@@ -342,8 +342,8 @@ static int close_open_file_descriptors(int write_fd, orte_iof_base_io_conf_t opt
342
342
return ORTE_SUCCESS ;
343
343
}
344
344
345
- static int do_child (orte_app_context_t * context ,
346
- orte_proc_t * child ,
345
+ static int do_child ( orte_proc_t * child ,
346
+ char * app , char * * argv ,
347
347
char * * environ_copy ,
348
348
orte_job_t * jobdat , int write_fd ,
349
349
orte_iof_base_io_conf_t opts )
@@ -375,7 +375,7 @@ static int do_child(orte_app_context_t* context,
375
375
send_error_show_help (write_fd , 1 ,
376
376
"help-orte-odls-alps.txt" ,
377
377
"iof setup failed" ,
378
- orte_process_info .nodename , context -> app );
378
+ orte_process_info .nodename , app );
379
379
/* Does not return */
380
380
}
381
381
@@ -399,30 +399,18 @@ static int do_child(orte_app_context_t* context,
399
399
close (fdnull );
400
400
}
401
401
402
- /* if the user requested it, set the system resource limits */
403
- if (OPAL_SUCCESS != (rc = opal_util_init_sys_limits (& msg ))) {
404
- send_error_show_help (write_fd , 1 , "help-orte-odls-alps.txt" ,
405
- "set limit" ,
406
- orte_process_info .nodename , context -> app ,
407
- __FILE__ , __LINE__ , msg );
408
- }
409
- /* ensure we only do this once */
410
- (void ) mca_base_var_env_name ("opal_set_max_sys_limits" , & param );
411
- opal_unsetenv (param , & environ_copy );
412
- free (param );
413
-
414
402
if (ORTE_SUCCESS != close_open_file_descriptors (write_fd , opts )) {
415
403
send_error_show_help (write_fd , 1 , "help-orte-odls-alps.txt" ,
416
404
"close fds" ,
417
- orte_process_info .nodename , context -> app ,
405
+ orte_process_info .nodename , app ,
418
406
__FILE__ , __LINE__ );
419
407
}
420
408
421
409
422
- if (context -> argv == NULL ) {
423
- context -> argv = malloc (sizeof (char * )* 2 );
424
- context -> argv [0 ] = strdup (context -> app );
425
- context -> argv [1 ] = NULL ;
410
+ if (argv == NULL ) {
411
+ argv = malloc (sizeof (char * )* 2 );
412
+ argv [0 ] = strdup (app );
413
+ argv [1 ] = NULL ;
426
414
}
427
415
428
416
/* Set signal handlers back to the default. Do this close to
@@ -449,25 +437,25 @@ static int do_child(orte_app_context_t* context,
449
437
450
438
if (10 < opal_output_get_verbosity (orte_odls_base_framework .framework_output )) {
451
439
int jout ;
452
- opal_output (0 , "%s STARTING %s" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), context -> app );
453
- for (jout = 0 ; NULL != context -> argv [jout ]; jout ++ ) {
454
- opal_output (0 , "%s\tARGV[%d]: %s" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), jout , context -> argv [jout ]);
440
+ opal_output (0 , "%s STARTING %s" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), app );
441
+ for (jout = 0 ; NULL != argv [jout ]; jout ++ ) {
442
+ opal_output (0 , "%s\tARGV[%d]: %s" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), jout , argv [jout ]);
455
443
}
456
444
for (jout = 0 ; NULL != environ_copy [jout ]; jout ++ ) {
457
445
opal_output (0 , "%s\tENVIRON[%d]: %s" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), jout , environ_copy [jout ]);
458
446
}
459
447
}
460
448
461
- execve (context -> app , context -> argv , environ_copy );
449
+ execve (app , argv , environ_copy );
462
450
send_error_show_help (write_fd , 1 ,
463
451
"help-orte-odls-alps.txt" , "execve error" ,
464
- orte_process_info .nodename , context -> app , strerror (errno ));
452
+ orte_process_info .nodename , app , strerror (errno ));
465
453
/* Does not return */
466
454
}
467
455
468
456
469
- static int do_parent (orte_app_context_t * context ,
470
- orte_proc_t * child ,
457
+ static int do_parent (orte_proc_t * child ,
458
+ char * app , char * * argv ,
471
459
char * * environ_copy ,
472
460
orte_job_t * jobdat , int read_fd ,
473
461
orte_iof_base_io_conf_t opts )
@@ -476,19 +464,10 @@ static int do_parent(orte_app_context_t* context,
476
464
orte_odls_pipe_err_msg_t msg ;
477
465
char file [ORTE_ODLS_MAX_FILE_LEN + 1 ], topic [ORTE_ODLS_MAX_TOPIC_LEN + 1 ], * str = NULL ;
478
466
479
- if (NULL != child && ORTE_FLAG_TEST (jobdat , ORTE_JOB_FLAG_FORWARD_OUTPUT )) {
480
- /* connect endpoints IOF */
481
- rc = orte_iof_base_setup_parent (& child -> name , & opts );
482
- if (ORTE_SUCCESS != rc ) {
483
- ORTE_ERROR_LOG (rc );
484
- close (read_fd );
485
-
486
- if (NULL != child ) {
487
- child -> state = ORTE_PROC_STATE_UNDEF ;
488
- }
489
- return rc ;
490
- }
491
- }
467
+ close (opts .p_stdin [0 ]);
468
+ close (opts .p_stdout [1 ]);
469
+ close (opts .p_stderr [1 ]);
470
+ close (opts .p_internal [1 ]);
492
471
493
472
/* Block reading a message from the pipe */
494
473
while (1 ) {
@@ -525,7 +504,7 @@ static int do_parent(orte_app_context_t* context,
525
504
if (OPAL_SUCCESS != rc ) {
526
505
orte_show_help ("help-orte-odls-alps.txt" , "syscall fail" ,
527
506
true,
528
- orte_process_info .nodename , context -> app ,
507
+ orte_process_info .nodename , app ,
529
508
"opal_fd_read" , __FILE__ , __LINE__ );
530
509
if (NULL != child ) {
531
510
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -539,7 +518,7 @@ static int do_parent(orte_app_context_t* context,
539
518
if (OPAL_SUCCESS != rc ) {
540
519
orte_show_help ("help-orte-odls-alps.txt" , "syscall fail" ,
541
520
true,
542
- orte_process_info .nodename , context -> app ,
521
+ orte_process_info .nodename , app ,
543
522
"opal_fd_read" , __FILE__ , __LINE__ );
544
523
if (NULL != child ) {
545
524
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -553,7 +532,7 @@ static int do_parent(orte_app_context_t* context,
553
532
if (NULL == str ) {
554
533
orte_show_help ("help-orte-odls-alps.txt" , "syscall fail" ,
555
534
true,
556
- orte_process_info .nodename , context -> app ,
535
+ orte_process_info .nodename , app ,
557
536
"opal_fd_read" , __FILE__ , __LINE__ );
558
537
if (NULL != child ) {
559
538
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -602,39 +581,16 @@ static int do_parent(orte_app_context_t* context,
602
581
/**
603
582
* Fork/exec the specified processes
604
583
*/
605
- static int odls_alps_fork_local_proc (orte_app_context_t * context ,
606
- orte_proc_t * child ,
607
- char * * environ_copy ,
608
- orte_job_t * jobdat )
584
+ static int odls_alps_fork_local_proc (orte_proc_t * child ,
585
+ char * app ,
586
+ char * * argv ,
587
+ char * * environ_copy ,
588
+ orte_job_t * jobdat ,
589
+ orte_iof_base_io_conf_t opts )
609
590
{
610
- orte_iof_base_io_conf_t opts ;
611
591
int rc , p [2 ];
612
592
pid_t pid ;
613
593
614
- if (NULL != child ) {
615
- /* should pull this information from MPIRUN instead of going with
616
- default */
617
- opts .usepty = OPAL_ENABLE_PTY_SUPPORT ;
618
-
619
- /* do we want to setup stdin? */
620
- if (NULL != child &&
621
- (jobdat -> stdin_target == ORTE_VPID_WILDCARD ||
622
- child -> name .vpid == jobdat -> stdin_target )) {
623
- opts .connect_stdin = true;
624
- } else {
625
- opts .connect_stdin = false;
626
- }
627
-
628
- if (ORTE_SUCCESS != (rc = orte_iof_base_setup_prefork (& opts ))) {
629
- ORTE_ERROR_LOG (rc );
630
- if (NULL != child ) {
631
- child -> state = ORTE_PROC_STATE_FAILED_TO_START ;
632
- child -> exit_code = rc ;
633
- }
634
- return rc ;
635
- }
636
- }
637
-
638
594
/* A pipe is used to communicate between the parent and child to
639
595
indicate whether the exec ultimately succeeded or failed. The
640
596
child sets the pipe to be close-on-exec; the child only ever
@@ -668,16 +624,16 @@ static int odls_alps_fork_local_proc(orte_app_context_t* context,
668
624
}
669
625
670
626
if (pid == 0 ) {
671
- close (p [0 ]);
627
+ close (p [0 ]);
672
628
#if HAVE_SETPGID
673
629
setpgid (0 , 0 );
674
630
#endif
675
- do_child (context , child , environ_copy , jobdat , p [1 ], opts );
631
+ do_child (child , app , argv , environ_copy , jobdat , p [1 ], opts );
676
632
/* Does not return */
677
633
}
678
634
679
635
close (p [1 ]);
680
- return do_parent (context , child , environ_copy , jobdat , p [0 ], opts );
636
+ return do_parent (child , app , argv , environ_copy , jobdat , p [0 ], opts );
681
637
}
682
638
683
639
0 commit comments