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/commit] Handle EOF on terminals opened with ENONBLOCK...


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


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