pipe

Hello

I want to determine the max. size for a pipe. I saw the following programm in a C-Programming book.

#include
#include
#include
#include
#include

int main(void)
{
int i, n, fd[2];
fd_set schreibmenge;
struct timeval zeitwert;
if (pipe(fd) < 0)
ex();
FD_ZERO(&schreibmenge);
for (n = 0; 1; n++) { /* write 1 Byte until pipe is full */
FD_SET(fd[1], &schreibmenge);
zeitwert.tv_sec = zeitwert.tv_usec = 0; /* no waiting */
if ((i = select(fd[1]+1, NULL, &schreibmenge, NULL, &zeitwert)) < 0)
ex();
else if (i > 0) {
if (write(fd[1], "X", 1) != 1)
ex();
} else
break;
}
printf("--- highest Pipe-size = %d; PIPE_BUF = %d ---
", n, PIPE_BUF);
exit(0);
}

I always get the result '1'. This can't be! Where could be the error in this programm?
i hope you can help me.

Jannet Miller

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories