This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/commit] Handle EOF on terminals opened with ENONBLOCK...
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: brobecker at adacore dot com
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 23 Apr 2009 21:34:07 +0200 (CEST)
- Subject: Re: [RFA/commit] Handle EOF on terminals opened with ENONBLOCK...
- References: <20090423191446.GB7512@adacore.com>
> Date: Thu, 23 Apr 2009 12:14:46 -0700
> From: Joel Brobecker <brobecker@adacore.com>
>
> 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 <brobecker@adacore.com>
>
> * 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.