/* ** speak.c -- writes into a FIFO */ #include #include #include #include #include #include #include #include #define FIFO_NAME "american_maid" main() { char s[300]; int num, fd; mknod(FIFO_NAME, S_IFIFO | 0666, 0); printf("waiting for readers...\n"); fd = open(FIFO_NAME, O_WRONLY); printf("got a reader--type some stuff\n"); while (gets(s), !feof(stdin)) { if ((num = write(fd, s, strlen(s))) == -1) perror("write"); else printf("speak: wrote %d bytes\n", num); } }