From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24647 invoked by alias); 12 Apr 2007 16:46:02 -0000 Received: (qmail 24638 invoked by uid 22791); 12 Apr 2007 16:46:01 -0000 X-Spam-Check-By: sourceware.org Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 12 Apr 2007 17:45:59 +0100 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id 8E41C48CF6B for ; Thu, 12 Apr 2007 12:45:57 -0400 (EDT) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 05189-01-8 for ; Thu, 12 Apr 2007 12:45:57 -0400 (EDT) Received: from joel.gnat.com (dhcp-guest.act-europe.fr [212.157.227.127]) by nile.gnat.com (Postfix) with ESMTP id 05D2F48CC4F for ; Thu, 12 Apr 2007 12:45:57 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id D480AE7B4C; Thu, 12 Apr 2007 18:47:44 +0200 (CEST) Date: Thu, 12 Apr 2007 16:46:00 -0000 From: Joel Brobecker To: gdb@sourceware.org Subject: Re: [mingw32] stdin redirection Message-ID: <20070412164744.GL3886@adacore.com> References: <20070411134219.GA33609@adacore.com> <20070411144451.GA21140@caradoc.them.org> <20070411145104.GE58502@adacore.com> <20070411151234.GA22185@caradoc.them.org> <20070412145818.GG3886@adacore.com> <20070412151221.GA856@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070412151221.GA856@caradoc.them.org> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00080.txt.bz2 > For a pipe, we use PeekNamedPipe to figure out how many bytes are > available in the pipe and whether select on the pipe should return. > For a file, we use the fallback case: we pass the file's HANDLE to > WaitForMultipleObjects. What does a file HANDLE do when waited on? > Maybe it's not the useful behavior. I see what you mean now. I had a look at the MSDN documentation for that function: They list the types of handles that can be used, and they do not list files. However: They do not list pipes either. So I'm wondering whether I'm looking at the right thing at all... The WaitForMultipleObjects function can specify handles of any of the following object types in the lpHandles array: * Change notification * Console input * Event * Memory resource notification * Mutex * Process * Semaphore * Thread * Waitable timer The only information we have at this point is that our experience seems to show that WaitForMultipleObjects on a file seems to be working. That is, working unless we did a PeekNamedPipe on its handle beforehand... > > If we could find a way to replace the current implementation of > > fd_is_pipe into something that avoids using any of the pipe functions, > > then that would probably solve our problem. Unfortunately, despite > > our intensive search of MSDN, nothing turned up. > > To the best of my knowledge there is no way. That's what we though too :-(. > Are you sure that you tested any case in which fd_is_pipe returned > true? I just re-verified (see earlier email in that thread). I had a look at what we were doing in gdb-6.4 (where things worked for us), and we were actually doing a waitForMultipleObject call for all handles unconditionally. So it's not so surprising that Jerome's hack "works", it just reproduces the older behavior... Your point about WaitForMultipleObjects regarding file handles seem to suggest that we should be using something else for these types of handle (I guess just fake a read-available event since we'll always have something to read until we reach EOF). But the issue remains the same though: How do we determine that we're actually dealing with a file handle??? -- Joel