The following code behaves differently in Ubuntu 18.04 and 19.04.
In 18.04 the computer waits for input of the string as it should.
In 19.04 the computer does not wait and terminates (but shouldn't). It appears to be affected by the previous code even though it shouldn't because term was fully restored.
why ?
(note that the computer in the test running Ubuntu 19.04 is about 2x faster than the one running 18.04 although I don't think this should affect anything)
#include <termios.h>
int main(int args, char * argp[]) {
using namespace std;
termios before, after;
tcgetattr (STDIN_FILENO, &before);
after = before;
after.c_lflag &= (~ICANON);
after.c_lflag &= (~ECHO);
after.c_cc[VMIN]=0;
after.c_cc[VTIME]=0;
tcsetattr (STDIN_FILENO, TCSANOW, &after);
for(;;) {
auto ch = cin.get();
if (ch == EOF) {
cin.clear();
break;
}
}
tcsetattr (STDIN_FILENO, TCSANOW, &before);
string str;
std::getline(cin, str);
cout << str << endl;
return 0;
}