if ((mkfifo(FIFO1, FILE_MODE) < 0) && errno != EEXIST)
{//error
exit(0);
}
if ((mkfifo(FIFO2, FILE_MODE) < 0) && errno != EEXIST)
{//error
exit(0);
}
fprintf(stderr, "before open\n");
rfd = open(FIFO1, O_RDONLY, 0);
wfd = open(FIFO2, O_WRONLY, 0);
fprintf(stderr, "after open\n");
//到这里出现问题,after open一直没有打印出来。
}
man 3 open.一般3的解释较2的解释详细.
O_NONBLOCK
When opening a FIFO with O_RDONLY or O_WRONLY set:
* If O_NONBLOCK 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.