运行到open()函数卡住,怎么处理
运行到open()函数卡住,怎么办?
代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd;
if((fd = open("fifo1",O_WRONLY)) < 0) {
perror("打开失败。");
exit(1);
}
printf("%d",fd);
write(fd,"nihao",6);
close(fd);
return 0;
}
路径是正确的,但是控制台没有任何输出。谷歌又跳不了页面,真急死俺啦。。。。
Answers
学linux开发请认真看书, 自己瞎摸既学不好又浪费时间。
ONONBLOCK
When opening a FIFO with ORDONLY or OWRONLY set:
* If ONONBLOCK is set, an open() for reading-only shall return without delay. An open() for writing-only shall return an error if no
process currently has the file open for reading.
* If O_NONBLOCK is clear, an open() for reading-only shall block the calling thread until a thread opens the file for writing. An open()
for writing-only shall block the calling thread until a thread opens the file for reading.