pojmenovan roura
Pavel Kankovsky
peak na kerberos.troja.mff.cuni.cz
Pondělí Prosinec 8 19:06:05 CET 1997
On Mon, 8 Dec 1997, Ondrej Kamenik wrote:
> 1) zapisovatel vytvori pojmenovanou rouru
> 2) ctenar ji otevre ke cteni bez blokovani, tedy:
> fifo=open(cesta,O_RDONLY|O_NONBLOCK);
> 3) zacne cist volanim:
> char c;
> read(fifo,&c,1);
> tady bych ocekaval, ze read vrati -1 a v errno bude EWOULDBLOCK (nebo
> EAGAIN). Ale vono nic, volani read nezkolabuje a v c se mi objevovala 0.
ehmm---nevracel read() nulu?
> Otazka zni: proc to nefunguje tak, jak by clovek (kamenik) cekal?
semantika fifo je trochu zvlastni, kdybych tvrdil, ze ji rozumim, tak
bych kecal; ale podival jsem se do "Single User Specification 2"
(viz http://www.rdg.opengroup.org/)
When attempting to read from an empty pipe or FIFO:
* If no process has the pipe open for writing, read() will return 0 to
indicate end-of-file.
* If some process has the pipe open for writing and O_NONBLOCK is set,
read() will return -1 and set errno to [EAGAIN].
* If some process has the pipe open for writing and O_NONBLOCK is
clear, read() will block the calling thread until some data is
written or the pipe is closed by all processes that had the pipe
open for writing.
--Pavel Kankovsky aka Peak (troja.mff.cuni.cz network administration)
[ Boycott Microsoft -- http://www.vcnet.com/bms ]
Další informace o konferenci Linux