select() a pojmenovane fifo

Jiri Kosina jikos na jikos.cz
Pondělí Červenec 3 11:11:13 CEST 2006


On Fri, 30 Jun 2006, Petr Janda wrote:

> - pokud ji to neco zavre, tak 
>   - nedostanu SIGPIPE

SIGPIPE je dorucovan v pripade ze proces zapisuje do pipe kterou nikdo 
nema otevrenou pro cteni. Nevim jestli je toto vas pripad, spis bych rekl 
ze ne.

>   - select vraci okamzite 1 pri kazdem pruchodu smyckou - to me stve
>     nejvic
>   - pripadne cteni z fifo_file precte 0 byte a skonci s EOF

Viz SUSv2:

    When attempting to read from an empty pipe or FIFO:                        
 
     * If no process has the pipe open for writing, read()
       shall return 0 to indicate end-of-file.                                               
 
     * If some process has the pipe open for writing and
       O_NONBLOCK is set, read() shall return -1 and set
       errno to [EAGAIN].                      
 
     * If some process has the pipe open for writing and
       O_NONBLOCK is clear, read() shall block the calling
       thread until some data is written or the pipe is
       closed by all processes that had the pipe open for
       writing.                                                

Toto implikuje ze select() se nesmi zablokovat, pokud zadny proces nema 
dane FIFO otevrene pro zapis (protoze chovani select() zavisi na chovani 
jake by mel read() v pripade ze by O_NONBLOCK nebyl nastaven - opet viz 
SUSv2).

-- 
JiKos.


Další informace o konferenci Linux