#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(int argc,char *argv[]){ char *fifoname = "my_fifo"; mkfifo(fifoname,0666); int fd; if ((fd = open(fifoname,O_WRONLY | O_NONBLOCK)) == -1) { perror("open pipe"); exit(EXIT_FAILURE); } close(fd); exit(EXIT_SUCCESS);}解决方法 查看linux
fifo
手册页: A process can open a FIFO in nonblocking mode. In this case,opening
for read-only will succeed even if no-one has opened on the write
sIDe yet,opening for write-only will fail withENXIO
(no such device
or address) unless the other end has already been opened.
如果您想要非阻塞模式,则需要确保阅读器在编写器之前打开fifo.
总结以上是内存溢出为你收集整理的当我尝试打开一个FIFO O_WRONLY时,我收到“没有这样的设备或地址”错误全部内容,希望文章能够帮你解决当我尝试打开一个FIFO O_WRONLY时,我收到“没有这样的设备或地址”错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)