diff --git a/v2/engine/execunix.c b/v2/engine/execunix.c index 42777669f..35b6e7759 100644 --- a/v2/engine/execunix.c +++ b/v2/engine/execunix.c @@ -198,6 +198,10 @@ void exec_cmd if ( tps == 0 ) tps = sysconf( _SC_CLK_TCK ); } + /* Child does not need the read pipe ends used by the parent. */ + fcntl( out[ EXECCMD_PIPE_READ ], F_SETFD, FD_CLOEXEC ); + fcntl( err[ EXECCMD_PIPE_READ ], F_SETFD, FD_CLOEXEC ); + if ( ( cmdtab[ slot ].pid = vfork() ) == -1 ) { perror( "vfork" ); @@ -211,9 +215,6 @@ void exec_cmd /*****************/ int const pid = getpid(); - close( out[ EXECCMD_PIPE_READ ] ); - close( err[ EXECCMD_PIPE_READ ] ); - /* Redirect stdout and stderr to pipes inherited from the parent. */ dup2( out[ EXECCMD_PIPE_WRITE ], STDOUT_FILENO ); dup2( globs.pipe_action ? err[ EXECCMD_PIPE_WRITE ] :