From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13919 invoked by alias); 23 Apr 2009 19:35:03 -0000 Received: (qmail 13888 invoked by uid 22791); 23 Apr 2009 19:35:02 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Apr 2009 19:34:55 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id n3NJY7A4001570; Thu, 23 Apr 2009 21:34:08 +0200 (CEST) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id n3NJY7j7006691; Thu, 23 Apr 2009 21:34:07 +0200 (CEST) Date: Thu, 23 Apr 2009 19:35:00 -0000 Message-Id: <200904231934.n3NJY7j7006691@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: brobecker@adacore.com CC: gdb-patches@sourceware.org In-reply-to: <20090423191446.GB7512@adacore.com> (message from Joel Brobecker on Thu, 23 Apr 2009 12:14:46 -0700) Subject: Re: [RFA/commit] Handle EOF on terminals opened with ENONBLOCK... References: <20090423191446.GB7512@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00662.txt.bz2 > Date: Thu, 23 Apr 2009 12:14:46 -0700 > From: Joel Brobecker > > What happens is that, by the time GDB makes a read on the pseudo- > terminal, there is nothing to read yet, and thus gets EOF back. > The thing to do, to detect our case, is to check the errno value, > and try again a little later if it's EAGAIN. > > 2009-04-23 Joel Brobecker > > * utils.c: Add include of gdb_usleep.h. > (defaulted_query): Detect false EOF conditions that happen > on terminals opened with the O_NONBLOCK flag when there is > nothing to read. > > We've tested this patch on all the hosts that AdaCore supports. > This includes GNU/Linux, Solaris, AIX, Tru64, MinGW... > Would it be OK to commit? Ugh, yuck, this is gross! I suppose the errno == EAGAIN is supposed to check whether fgetc() failed. However, your code has an ferror() in between, which could clobber errno. So perhaps it is better to reverse those checks.