// gcc -Wall -Wextra -o client client.c #include #include #include #include #include #include #include #define FIFO_PATH "/tmp/myfifo" int main(int argc, char *argv[]) { int fd = -1; fd = open(FIFO_PATH, O_WRONLY); printf("fd = %d\n", fd); if (fd < 0) { fprintf(stderr, "Could not open fifo %s: %s\n", FIFO_PATH, strerror(errno)); return -1; } int flags = fcntl(fd, F_GETFL); if (flags == -1) fprintf(stderr, "fcntl F_GETFL: %s\n", strerror(errno)); printf("flags = 0%o\n", flags); if (argc > 1) { write(fd, argv[1], strlen(argv[1]) ); } else { write(fd, &"What ho!", 9); } // note: printf "What ho" > /tmp/myfifo from bash, would close the file descriptor. printf("Closing ... fd = %d\n", fd); close(fd); // EOF return 0; } //=====