named pipe is borken and proposed fix

Laurent Bercot ska-dietlibc at skarnet.org
Fri Jun 3 05:24:46 UTC 2011


>> It did not work. I am not sure whether it is possible to open same
>> FIFO, and use one as reader, and use second as writer, in same user
>> process.
> Of course it can. The easiest way to do this is open the FIFO with the
> O_RDWR flag. Then you will never get EOF.

 That will work on Linux, but is not portable.
 The portable way to achieve this would be something like:

 int fdr = open("fifo", O_RDONLY|O_NONBLOCK) ;
 int fdw = open("fifo", O_WRONLY) ;
 /* here make fdr blocking if necessary */
 do_something(fdr) ; /* totally ignoring fdw */
 close(fdw) ;
 close(fdr) ;

-- 
 Laurent


More information about the uClibc mailing list