>>>>> "Joacim" == Joacim Persson <[EMAIL PROTECTED]> writes:

Joacim> On Wed, 24 Feb 1999, Jean-Marc Lasgouttes wrote:
>> Actually this happens to me on Digital Unix 4.0.

Joacim> Is that SysV-ish or BSD? (just curious)

>From the 'standards' man page, it seems rather SysV-ish (and POSIX and
XPG).

Joacim> Now, I don't /know/ what goes on inside libforms.  

I do (I have the source :).


Joacim> I'm told there is a select -- well there have to be one -- 
Joacim> but maybe they do something else too, like checking the file
Joacim> descriptor's buffer for data whenever the select triggers on
Joacim> it and only call the callback if there actually is something
Joacim> in the buffer.  The libforms manual says the callback is
Joacim> called when the file descriptor "has data available", but the
Joacim> author could also have misunderstood the operation of select()
Joacim> I suppose.

They just call the callback when select triggers on the fd.

Joacim> Yes it looks a bit like putting jam on the jelly doesn't it?
Joacim> "Opening a file non-blocking, and then /select/ over it!?!?"
Joacim> ;)

Didn't I told you that I do not understand it all? %-]

Joacim> Another strange fact about named pipes is that an open() on
Joacim> one end won't return until the fifo is open()ed in the other
Joacim> end too, unless it is opened with O_NONBLOCK. (an unnamed pipe
Joacim> is allways opened on both ends simultaneously, with pipe(2),
Joacim> so no broken pipes there)

Maybe the following description from the read() man page can make some
sense to you...

  When attempting to read from an empty pipe (or FIFO):

    +  If no process has the pipe open for writing, the read() function
       returns 0 (zero) to indicate end-of-file.

    +  If some process has the pipe open for writing and O_NONBLOCK is set,
       the read() function returns a value of -1 and sets errno to [EAGAIN].

    +  If some process has the pipe open for writing and O_NONBLOCK is clear,
       the read() function will block until some data is written or the pipe
       is closed by all processes that had opened the pipe for writing.

    +  [Digital]  If some process has the pipe open for writing and O_NDELAY
       is set, the read() function returns a value of -1 and sets errno to
       [EAGAIN].

    +  [Digital]  If some process has the pipe open for writing and O_NDELAY
       is clear, the read() function will block until some data is written or
       the pipe is closed by all processes that had opened the pipe for writ-
       ing.

Joacim> ...maybe if we open it non-blocking, and set it to blocking
Joacim> /after/ the call to fl_add_io_callback, with fcntl()?  Then
Joacim> the lines for "resetting the connection" could/should probably
Joacim> be taken out too.  I'm not sure what happens when the client
Joacim> closes its end of the fifo in that case.  I'm afraid we must
Joacim> have a signal handler for SIGPIPE too.  :P

If you provide me with a patch, I can try it out.

JMarc

Reply via email to