This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] PR5820: two CTRL-D are not enough?!?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sun, 31 Mar 2002 14:18:05 +0200
- Subject: [RFC] PR5820: two CTRL-D are not enough?!?
Hi,
this is one of weirdest PR I have seen in the last months and I have no
idea if the current behaviour of v3 is conforming or not in this respect.
Submitter maintains that usually two CTRL-D indicates end of output,
whereas v3 needs /four/.
This is the original testcase:
#include <iostream>
int main()
{
int i;
char c;
std::cout << "Enter an integer: ";
std::cin >> i;
if (!std::cin) {
std::cerr << "Unexpected read problem\n";
return 1;
}
std::cout << '\n' << "std::cin.eof()=" << std::cin.eof() << '\n';
std::cout << "The number was: " << i << '\n';
std::cin >> c;
if (std::cin) {
std::cerr << "Could read " << c << " after the number!\n";
}
}
I have confirmed that this happens on linux and the following is an
excerpt of a trace (after a "5" I had to press CTRL-D four times):
...
SYS_197(0, 0xbffff610, 0, 0xbffff610, 0) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x400c6000
read(0, "5", 4096) = 1
_llseek(0, -1, 0xbffff550, SEEK_CUR) = -1 ESPIPE (Illegal seek)
_llseek(0, 0, 0xbffff550, SEEK_CUR) = -1 ESPIPE (Illegal seek)
_llseek(0, 1, 0xbffff410, SEEK_CUR) = -1 ESPIPE (Illegal seek)
_llseek(0, 0, 0xbffff410, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, "", 4096) = 0
_llseek(0, 1, 0xbffff420, SEEK_CUR) = -1 ESPIPE (Illegal seek)
_llseek(0, 0, 0xbffff420, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, "", 4096) = 0
_llseek(0, 1, 0xbffff420, SEEK_CUR) = -1 ESPIPE (Illegal seek)
_llseek(0, 0, 0xbffff420, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, "", 4096) = 0
write(1, "\n", 1) = 1
...
In fact, the same testcase compiled by icc is not affected by the
"problem"...
Opinions?
Ciao, Paolo.