From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23556 invoked by alias); 5 Feb 2006 00:01:17 -0000 Received: (qmail 23548 invoked by uid 22791); 5 Feb 2006 00:01:17 -0000 X-Spam-Check-By: sourceware.org Received: from yosemite.airs.com (HELO yosemite.airs.com) (205.217.158.180) by sourceware.org (qpsmtpd/0.31) with SMTP; Sun, 05 Feb 2006 00:01:15 +0000 Received: (qmail 26456 invoked by uid 10); 5 Feb 2006 00:01:14 -0000 Received: (qmail 16637 invoked by uid 500); 5 Feb 2006 00:01:07 -0000 To: Daniel Jacobowitz Cc: gdb-patches@sourceware.org Subject: Re: RFA: Various Windows (mingw32) additions, mostly relating to select or serial ports References: <20060203220529.GA3578@nevyn.them.org> <20060204145911.GC17011@nevyn.them.org> From: Ian Lance Taylor Date: Sun, 05 Feb 2006 00:01:00 -0000 In-Reply-To: <20060204145911.GC17011@nevyn.them.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00089.txt.bz2 Daniel Jacobowitz 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