1 #include <sys/select.h>
10 #define BIG_PIPE_SIZE 64*1024 /* From sys/pipe.h */
13 * Test for the non-blocking big pipe bug (write(2) returning
14 * EAGAIN while select(2) returns the descriptor as ready for write).
20 write_frame(int fd, char *buf, unsigned long buflen)
28 i = select(fd+1, NULL, &wfd, NULL, NULL);
30 err(1, "select failed");
32 errx(1, "select returned unexpected value %d\n", i);
35 i = write(fd, buf, buflen);
49 /* any value over PIPE_SIZE should do */
50 char buf[BIG_PIPE_SIZE];
54 errx(1, "pipe failed");
56 flags = fcntl(fd[1], F_GETFL);
57 if (flags == -1 || fcntl(fd[1], F_SETFL, flags|O_NONBLOCK) == -1) {
58 printf("fcntl failed: %s\n", strerror(errno));
64 err(1, "fork failed: %s\n", strerror(errno));
69 /* Any small size should do */
70 i = read(fd[0], buf, 256);
82 memset(buf, 0, sizeof buf);
83 for (i = 0; i < 1000; i++)
84 write_frame(fd[1], buf, sizeof buf);