Jannet Miller
June 29th, 2001, 05:28 AM
Hello
I hope i'm right in this forum here.
I want to determine the highest size for a pipe and I saw the following programm in a C-Programming book.
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <limits.h>
#include <sys/types.h>
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", n, PIPE_BUF);
exit(0);
}
I always get the result '1'. Where could be the error in this programm?
i hope you can help me.
Jannet Miller
I hope i'm right in this forum here.
I want to determine the highest size for a pipe and I saw the following programm in a C-Programming book.
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <limits.h>
#include <sys/types.h>
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", n, PIPE_BUF);
exit(0);
}
I always get the result '1'. Where could be the error in this programm?
i hope you can help me.
Jannet Miller