读书人

fopen 打开定名管道阻塞

发布时间: 2012-08-02 11:35:26 作者: rapoo

fopen 打开命名管道阻塞

使用fopen以写的方式打开命名管道,若没有别的进程/线程以读的方式打开命名管道,该函数将一直阻塞。

?写道O_NONBLOCK
When opening a FIFO with O_RDONLY or O_WRONLY set: If O_NONBLOCK is set:
An open() for reading only will return without delay. An open() for writing only will return an error if no process currently has the file open for reading.
If O_NONBLOCK is clear:
An open() for reading only will block the calling thread until a thread opens the file for writing. An open() for writing only will block the calling thread until a thread opens the file for reading.

?

参考?http://pubs.opengroup.org/onlinepubs/007908799/xsh/open.htmlhttp://stackoverflow.com/questions/580013/how-do-i-perform-a-non-blocking-fopen-on-a-named-pipe-mkfifoLinux命名管道FIFO的读写规则

?

?

读书人网 >移动开发

热点推荐