#include #include #include #include #include #include #include #define MAX_BUF 1024 int main() { int fd; char * myfifo = "/tmp/myfifo"; char buf[MAX_BUF]; /* open, read, and display the message from the FIFO */ fd = open(myfifo, O_RDONLY); if ( fd < 0 ) { perror(myfifo); return EXIT_FAILURE; } ssize_t nRead = read(fd, buf, MAX_BUF); if ( nRead < 0 ) { if ( errno == EINTR ) fprintf(stderr, "Didn't read -- interrupted.\n"); else perror(NULL); return EXIT_FAILURE; } printf("Received: %s\n", buf); close(fd); return EXIT_SUCCESS; }