DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2107
Version: 1.1.9


I find that, under WIN32, Fl::add_fd works only superficially when the
monitored file descriptor is an anonymous pipe. I don't know if you know
that already perfectly, but the documentation is silent on this subject.
(Under Mac OS X and X11, add_fd works beautifully on pipes.)
If data comes steadily from the pipe, all is well, but if the pipe remains
empty for a long time, this happens:
Fl::wait() calls select
select returns that the fd is to be read (note that select is sold for
sockets on WIN32, not for pipes)
Fl::wait() calls the fd's callback
which calls read(fd,...)
which blocks until some data arrives in the pipe.

The result is that the GUI, blocked in Fl::wait(), is frozen.

So I use the following code, that does not block when the pipe is empty,
to monitor pipe incoming data:
DWORD avail = 0;
//is there data in pipe ?
PeekNamedPipe(_get_osf_handle(fd), NULL,0,NULL, &avail, NULL);
if(avail > 0) read(fd,...) //read data from pipe

Another call that correctly detects whether there is data to be read in
the pipe is:
if( WaitForSingleObject(_get_osf_handle(fd), 0) == WAIT_OBJECT_0)
but it is unclear for me how to detect pipe closure by its writer,
so all of this does not really solve how to write under WIN32 Fl::wait()
generically for any fd as it is under Unix.


Link: http://www.fltk.org/str.php?L2107
Version: 1.1.9

_______________________________________________
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to