Close the pipe when exec is called.
exec
const PIPE_CLOSE_ON_EXEC: PipeFlags = PipeFlags(O_CLOEXEC);
pipe(2) and O_CLOEXEC therein