7 /* fifo server test program
11 /* fifo_rdwr_bug creates a FIFO and opens it read-write mode.
12 /* On BSD/OS 3.1 select() will report that the FIFO is readable
13 /* even before any data is written to it. Doing an actual read
14 /* causes the read to block; a non-blocking read fails.
16 /* Problems are reported to the standard error stream.
20 /* The Secure Mailer license must be distributed with this software.
23 /* IBM T.J. Watson Research
25 /* Yorktown Heights, NY 10598, USA
30 #include <sys/param.h>
39 #define FIFO_PATH "test-fifo"
40 #define perrorexit(s) { perror(s); exit(1); }
42 static void cleanup(void)
44 printf("Removing fifo %s...\n", FIFO_PATH
);
45 if (unlink(FIFO_PATH
))
50 int main(int unused_argc
, char **unused_argv
)
57 (void) unlink(FIFO_PATH
);
59 printf("Creating fifo %s...\n", FIFO_PATH
);
60 if (mkfifo(FIFO_PATH
, 0600) < 0)
63 printf("Opening fifo %s, read-write mode...\n", FIFO_PATH
);
64 if ((fd
= open(FIFO_PATH
, O_RDWR
, 0)) < 0) {
69 printf("Selecting the fifo for readability...\n");
71 FD_SET(fd
, &read_fds
);
73 FD_SET(fd
, &except_fds
);
77 switch (select(fd
+ 1, &read_fds
, (fd_set
*) 0, &except_fds
, &tv
)) {
81 if (FD_ISSET(fd
, &read_fds
)) {
82 printf("Opening a fifo read-write makes it readable!!\n");
86 printf("The fifo is not readable, as it should be.\n");