From d30d7f54c1c691aaa83b7700daf02daf321f1540 Mon Sep 17 00:00:00 2001
From: tewk <tewk@unknown>
Date: Mon, 12 Aug 2002 20:57:53 +0000
Subject: [PATCH] Fixed deadlock on forked_io threads

---
 src/slurmd/forked_io.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/slurmd/forked_io.c b/src/slurmd/forked_io.c
index 17b42686c7a..36ed028858c 100644
--- a/src/slurmd/forked_io.c
+++ b/src/slurmd/forked_io.c
@@ -37,6 +37,7 @@
 int forward_io ( task_start_t * task_start ) 
 {
 	pid_t cpid ;
+	int * pipes = task_start -> pipes ;
 
 #define FORK_ERROR -1
 
@@ -53,6 +54,11 @@ int forward_io ( task_start_t * task_start )
 			goto return_label;
 			break;
 		case 0 : /*CHILD*/
+			close ( pipes[CHILD_IN_RD_PIPE] );
+			close ( pipes[CHILD_OUT_RD_PIPE] );
+			close ( pipes[CHILD_OUT_WR_PIPE] );
+			close ( pipes[CHILD_ERR_RD_PIPE] );
+			close ( pipes[CHILD_ERR_WR_PIPE] );
 			stdin_io_pipe_thread ( task_start ) ;
 			_exit( 0 ) ;
 			break;
@@ -67,6 +73,11 @@ int forward_io ( task_start_t * task_start )
 			goto kill_stdin_thread;
 			break;
 		case 0 : /*CHILD*/
+			close ( pipes[CHILD_IN_RD_PIPE] );
+			close ( pipes[CHILD_IN_WR_PIPE] );
+			close ( pipes[CHILD_OUT_WR_PIPE] );
+			close ( pipes[CHILD_ERR_RD_PIPE] );
+			close ( pipes[CHILD_ERR_WR_PIPE] );
 			stdout_io_pipe_thread ( task_start ) ;
 			_exit( 0 ) ;
 			break;
@@ -81,6 +92,11 @@ int forward_io ( task_start_t * task_start )
 			goto kill_stdout_thread;
 			break;
 		case 0 : /*CHILD*/
+			close ( pipes[CHILD_IN_RD_PIPE] );
+			close ( pipes[CHILD_IN_WR_PIPE] );
+			close ( pipes[CHILD_OUT_RD_PIPE] );
+			close ( pipes[CHILD_OUT_WR_PIPE] );
+			close ( pipes[CHILD_ERR_WR_PIPE] );
 			stderr_io_pipe_thread ( task_start ) ;
 			_exit( 0 ) ;
 			break;
@@ -91,11 +107,11 @@ int forward_io ( task_start_t * task_start )
 
 	goto return_label;
 
-	kill_stdout_thread:
-		kill ( task_start->io_pthread_id[STDOUT_FILENO] , SIGKILL );
-	kill_stdin_thread:
-		kill ( task_start->io_pthread_id[STDIN_FILENO] , SIGKILL );
-	return_label:
+kill_stdout_thread:
+	kill ( task_start->io_pthread_id[STDOUT_FILENO] , SIGKILL );
+kill_stdin_thread:
+	kill ( task_start->io_pthread_id[STDIN_FILENO] , SIGKILL );
+return_label:
 	return SLURM_SUCCESS ;
 }
 
-- 
GitLab