This is the mail archive of the
mailing list for the libstdc++ project.
Re: libstdc++/9533: Regression: Can't read from tty with ifstream
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Pétur Runólfsson <peturr02 at ru dot is>
- Cc: paolo at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Mon, 03 Mar 2003 14:16:37 +0100
- Subject: Re: libstdc++/9533: Regression: Can't read from tty with ifstream
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F553F@nike.hir.is>
Pétur Runólfsson wrote:
Yes, you are right. My bad.
Patching: indeed, reverting this hunk of 6746 commit:
+ // Set input to nonblocking for fifos.
+ if (__mode & ios_base::in)
+ fcntl(this->fd(), F_SETFL, O_NONBLOCK);
Fixes the problem without regressing on 6746.
Interesting. I would have thought that removing this would
cause the call to underflow() in basic_filebuf::open() to
block, causing the test case to wait for input *before*
printing out the prompt (this seems to be the reason that
non-blocking input is specified).
I didn't notice that since was using a further reduced :( testcase.
Also, we got a regression elsewhere by simply reverting that hunk (not
on 6746): see
the libstdc++ list.
So far, this is what I think is going on:
* non-blocking input is specified so underflow() doesn't
block (which is wrong, underflow() should block).
* underflow() must not block because it is called from
open() which must not block.
* open() calls underflow() so that in_avail() will return
non-zero after open() (libstdc++/6746).
I concur, but in fact it does.
However, I don't see how calling underflow() from open()
Unless I am missing something,Paolo.
readsome will return up to BUFSIZ characters, and then
return 0 until the end of time.