#include #include #include #include #include #include int main(int argc, char *argv[]) { int fd; int ret; ret = mkfifo("my_fifo", 0666); if(ret != 0) { perror("mkfifo"); } printf("before open\n"); fd = open("my_fifo", O_WRONLY); //等着只读 if(fd < 0) { perror("open fifo"); } printf("after open\n"); sleep(5); char send[100] = "100"; write(fd, send, strlen(send)); printf("write to my_fifo buf=%s\n", send); while (1) { /* code */ } return 0; }