diff --git a/src/slurmd/io.c b/src/slurmd/io.c index 2179048acf63a534cc293ac7aa70a999809e05aa..e8c8fbf982056ad0ecb84197b30cd7263a56013b 100644 --- a/src/slurmd/io.c +++ b/src/slurmd/io.c @@ -44,7 +44,7 @@ int forward_io ( task_start_t * task_start ) #define STDIN_OUT_SOCK 0 #define SIG_STDERR_SOCK 1 - posix_signal_pipe_ignore ( ) ; + //posix_signal_pipe_ignore ( ) ; /* open stdout*/ connect_io_stream ( task_start , STDIN_OUT_SOCK ) ; @@ -62,16 +62,7 @@ int forward_io ( task_start_t * task_start ) if ( pthread_create ( & task_start->io_pthread_id[STDERR_FILENO] , NULL , stderr_io_pipe_thread , task_start ) ) goto kill_stdout_thread; - /* threads have been detatched*/ - pthread_join ( task_start->io_pthread_id[STDERR_FILENO] , NULL ) ; - info ( "errexit" ) ; - pthread_join ( task_start->io_pthread_id[STDOUT_FILENO] , NULL ) ; - info ( "outexit" ) ; - /*pthread_join ( task_start->io_pthread_id[STDIN_FILENO] , NULL ) ;*/ - pthread_cancel ( task_start->io_pthread_id[STDIN_FILENO] ); - info ( "inexit" ) ; - /* thread join on stderr or stdout signifies task termination we should kill the stdin thread */ goto return_label; @@ -83,6 +74,19 @@ int forward_io ( task_start_t * task_start ) return SLURM_SUCCESS ; } +int wait_on_io_threads ( task_start_t * task_start ) +{ + /* threads have been detatched*/ + pthread_join ( task_start->io_pthread_id[STDERR_FILENO] , NULL ) ; + info ( "errexit" ) ; + pthread_join ( task_start->io_pthread_id[STDOUT_FILENO] , NULL ) ; + info ( "outexit" ) ; + /*pthread_join ( task_start->io_pthread_id[STDIN_FILENO] , NULL ) ;*/ + pthread_cancel ( task_start->io_pthread_id[STDIN_FILENO] ); + info ( "inexit" ) ; + /* thread join on stderr or stdout signifies task termination we should kill the stdin thread */ +} + void * stdin_io_pipe_thread ( void * arg ) { task_start_t * task_start = ( task_start_t * ) arg ; @@ -280,6 +284,8 @@ void * stderr_io_pipe_thread ( void * arg ) init_circular_buffer ( & cir_buf ) ; + posix_signal_pipe_ignore ( ) ; + while ( true ) { if ( ( cir_buf->write_size == 0 ) ) diff --git a/src/slurmd/pipes.c b/src/slurmd/pipes.c index ab4ec75544ca0f8fed8ab363cbcad5722bbe1643..dc5660060f5fe844ff82dc1f0def432ee01d42c7 100644 --- a/src/slurmd/pipes.c +++ b/src/slurmd/pipes.c @@ -14,9 +14,17 @@ void setup_parent_pipes ( int * pipes ) void cleanup_parent_pipes ( int * pipes ) { + +/* + close ( pipes[CHILD_IN_RD] ) ; + close ( pipes[CHILD_OUT_WR] ) ; + close ( pipes[CHILD_ERR_WR] ) ; +*/ +// info ( " %i , %i , %i ", pipes[CHILD_IN_RD] , pipes[CHILD_OUT_WR] , pipes[CHILD_ERR_WR] ) ; close ( pipes[CHILD_IN_WR] ) ; close ( pipes[CHILD_OUT_RD] ) ; close ( pipes[CHILD_ERR_RD] ) ; +// info ( " %i , %i , %i ", pipes[CHILD_IN_WR] , pipes[CHILD_OUT_RD] , pipes[CHILD_ERR_RD] ) ; } int init_parent_pipes ( int * pipes ) diff --git a/src/slurmd/task_mgr.c b/src/slurmd/task_mgr.c index 63a1813e5198f4346db17ad973f0dba1f024bbf7..fc5a219fb1542965be9b59c09efa0c0f009eb048 100644 --- a/src/slurmd/task_mgr.c +++ b/src/slurmd/task_mgr.c @@ -126,6 +126,7 @@ void * task_exec_thread ( void * arg ) /* create pipes to read child stdin, stdout, sterr */ init_parent_pipes ( task_start->pipes ) ; + forward_io ( arg ) ; #define FORK_ERROR -1 #define CHILD_PROCCESS 0 @@ -190,8 +191,8 @@ void * task_exec_thread ( void * arg ) default: /*parent proccess */ task_start->exec_pid = cpid ; setup_parent_pipes ( task_start->pipes ) ; - forward_io ( arg ) ; waitpid ( cpid , & task_return_code , 0 ) ; + wait_on_io_threads ( task_start ) ; cleanup_parent_pipes ( task_start->pipes ) ; send_task_exit_msg ( task_return_code , task_start ) ; break;