Re: RFA: Various Windows (mingw32) additions, mostly relating to select or serial ports

Daniel Jacobowitz
2006-02-04T15:00:19Z

On Fri, Feb 03, 2006 at 10:28:16PM -0800, Ian Lance Taylor wrote:
> Daniel Jacobowitz <drow@false.org> writes:
>
> > The one I'm least proud of is pipes - there does not appear to be a way to
> > sleep and have the OS wake you when data is available on a pipe. So I poll
> > every 10ms in a thread. Yuck! The other three all have subtly different
> > wait mechanisms.
>
> Why do you have to poll? You should be able to have a thread which
> just sleeps on reading the pipe. When the thread reads something, it
> can signal the main thread, passing it the character which it read.

I am glad you asked. Oh, so glad. I can't read from the pipe, because
I can't pass the data to the main thread.

There's a dissimilarity between the console and pipe support, and the
serial and socket support. I used the serial.c interface for both
pairs, but the serial and socket devices are accessed exclusively from
the serial interface. On the other hand, that interface is only used
for managing TTY state (and now for select) for the other two. The
pipe I was interested in supporting was on stdin, and that gets
read from in all sorts of interesting places - like inside the
bowels of readline. If I read a character from the pipe, it's going
to get lost.

Pity there's no ungetc equivalent under the read() layer.

--
Daniel Jacobowitz
CodeSourcery