diff --git a/ksysguardd/Linux/softraid.c b/ksysguardd/Linux/softraid.c --- a/ksysguardd/Linux/softraid.c +++ b/ksysguardd/Linux/softraid.c @@ -215,7 +215,7 @@ char* mdadmStatBufP; /* Create a pipe */ - if(pipe(fd) == -1) + if(pipe2(fd, O_CLOEXEC) == -1) { perror("Could not create a pipe to launch mdadm."); exit(1); @@ -236,7 +236,6 @@ /* Child will execute the program, parent will listen. */ /* Close stdout, duplicate the input side of pipe to stdout */ dup2(fd[1], 1); - /* Close output side of pipe */ close(fd[0]); close(2); @@ -248,9 +247,6 @@ /* Parent process */ - /* Close input side of pipe */ - close(fd[1]); - waitpid( ChildPID, 0, 0); /* Fill mdadmStatBuf with pipe's output */ @@ -297,6 +293,10 @@ } } + /* Close pipe */ + close(fd[0]); + close(fd[1]); + /* Note: Don't test NumBlocksIsAlive, because it hasn't been set yet */ if ( (!MyArray->ArraySizeIsAlive && MyArray->ArraySizeIsRegistered ) || (!MyArray->UsedDeviceSizeIsAlive && MyArray->UsedDeviceSizeIsRegistered ) ||