This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Daniel Jacobowitz <drow@false.org> writes:

> > 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.

Well, OK, let's try this.  Create a new pipe.  Create yet another new
thread which reads from the original pipe and writes to the new pipe.
Freopen the new pipe onto stdin.  When the new thread writes to the
new pipe, it signals the event loop once, and then waits.  When the
event loop gets the signal, it indicates that it is OK to read from
stdin, the new pipe.  When you reenter the event loop, it signals the
new thread to tell it that it is interested in more data and more
signals.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]