15
15
* Copyright (c) 2010 IBM Corporation. All rights reserved.
16
16
* Copyright (c) 2011-2013 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,9 @@ static int orte_odls_default_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
+
148
+ static int do_child (orte_proc_t * child ,
149
+ char * cmd , char * * argv ,
149
150
char * * environ_copy ,
150
151
orte_job_t * jobdat , int write_fd ,
151
152
orte_iof_base_io_conf_t opts )
@@ -318,16 +319,15 @@ static int close_open_file_descriptors(int write_fd,
318
319
return ORTE_SUCCESS ;
319
320
}
320
321
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 ,
323
324
char * * environ_copy ,
324
325
orte_job_t * jobdat , int write_fd ,
325
326
orte_iof_base_io_conf_t opts )
326
327
{
327
- int i , rc ;
328
+ int i ;
328
329
sigset_t sigs ;
329
330
long fd , fdmax = sysconf (_SC_OPEN_MAX );
330
- char * param , * msg ;
331
331
332
332
#if HAVE_SETPGID
333
333
/* Set a new process group for this child, so that any
@@ -359,7 +359,7 @@ static int do_child(orte_app_context_t* context,
359
359
send_error_show_help (write_fd , 1 ,
360
360
"help-orte-odls-default.txt" ,
361
361
"iof setup failed" ,
362
- orte_process_info .nodename , context -> app );
362
+ orte_process_info .nodename , app );
363
363
/* Does not return */
364
364
}
365
365
}
@@ -384,18 +384,6 @@ static int do_child(orte_app_context_t* context,
384
384
close (fdnull );
385
385
}
386
386
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
-
399
387
/* close all open file descriptors w/ exception of stdin/stdout/stderr,
400
388
the pipe used for the IOF INTERNAL messages, and the pipe up to
401
389
the parent. */
@@ -408,10 +396,10 @@ static int do_child(orte_app_context_t* context,
408
396
}
409
397
}
410
398
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 ;
415
403
}
416
404
417
405
/* Set signal handlers back to the default. Do this close to
@@ -436,16 +424,16 @@ static int do_child(orte_app_context_t* context,
436
424
437
425
/* Exec the new executable */
438
426
439
- execve (context -> app , context -> argv , environ_copy );
427
+ execve (app , argv , environ_copy );
440
428
send_error_show_help (write_fd , 1 ,
441
429
"help-orte-odls-default.txt" , "execve error" ,
442
- orte_process_info .nodename , context -> app , strerror (errno ));
430
+ orte_process_info .nodename , app , strerror (errno ));
443
431
/* Does not return */
444
432
}
445
433
446
434
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 ,
449
437
char * * environ_copy ,
450
438
orte_job_t * jobdat , int read_fd ,
451
439
orte_iof_base_io_conf_t opts )
@@ -454,19 +442,10 @@ static int do_parent(orte_app_context_t* context,
454
442
orte_odls_pipe_err_msg_t msg ;
455
443
char file [ORTE_ODLS_MAX_FILE_LEN + 1 ], topic [ORTE_ODLS_MAX_TOPIC_LEN + 1 ], * str = NULL ;
456
444
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 ]);
470
449
471
450
/* Block reading a message from the pipe */
472
451
while (1 ) {
@@ -503,7 +482,7 @@ static int do_parent(orte_app_context_t* context,
503
482
if (OPAL_SUCCESS != rc ) {
504
483
orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
505
484
true,
506
- orte_process_info .nodename , context -> app ,
485
+ orte_process_info .nodename , app ,
507
486
"opal_fd_read" , __FILE__ , __LINE__ );
508
487
if (NULL != child ) {
509
488
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -517,7 +496,7 @@ static int do_parent(orte_app_context_t* context,
517
496
if (OPAL_SUCCESS != rc ) {
518
497
orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
519
498
true,
520
- orte_process_info .nodename , context -> app ,
499
+ orte_process_info .nodename , app ,
521
500
"opal_fd_read" , __FILE__ , __LINE__ );
522
501
if (NULL != child ) {
523
502
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -531,7 +510,7 @@ static int do_parent(orte_app_context_t* context,
531
510
if (NULL == str ) {
532
511
orte_show_help ("help-orte-odls-default.txt" , "syscall fail" ,
533
512
true,
534
- orte_process_info .nodename , context -> app ,
513
+ orte_process_info .nodename , app ,
535
514
"opal_fd_read" , __FILE__ , __LINE__ );
536
515
if (NULL != child ) {
537
516
child -> state = ORTE_PROC_STATE_UNDEF ;
@@ -580,39 +559,16 @@ static int do_parent(orte_app_context_t* context,
580
559
/**
581
560
* Fork/exec the specified processes
582
561
*/
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 ,
585
565
char * * environ_copy ,
586
- orte_job_t * jobdat )
566
+ orte_job_t * jobdat ,
567
+ orte_iof_base_io_conf_t opts )
587
568
{
588
- orte_iof_base_io_conf_t opts = {0 };
589
- int rc , p [2 ];
569
+ int p [2 ];
590
570
pid_t pid ;
591
571
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
-
616
572
/* A pipe is used to communicate between the parent and child to
617
573
indicate whether the exec ultimately succeeded or failed. The
618
574
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,
647
603
648
604
if (pid == 0 ) {
649
605
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 );
651
607
/* Does not return */
652
608
}
653
609
654
610
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 );
656
612
}
657
613
658
614
0 commit comments