作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上,如果我写:
struct termios raw;
tcgetattr(STDIN_FILENO, &raw);
raw.c_lflag &= ~(ECHO);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
为了不显示用户输入,c_lflag
中的一项更改如何允许 tcsetattr()
按预期工作?
最佳答案
您可以禁用 ECHO 以使输入不回显到输出,如下所示:
toptions.c_lflag &= ~(ECHO);
if (tcsetattr(fd, TCSANOW, &toptions) != 0)
{
cout << "ERROR: " << errno << " from tcsetattr" <<endl;
exit(1);
}
ECHO 定义为:
ECHO in c_lflag controls whether input is immediately re-echoed as output. It is independent of ICANON, although they are often turned on and off together. When passwd prompts for your password, your terminal is in canonical mode, but ECHO is disabled.
关于c - termios.h 如何使用位掩码来确定终端应该是什么模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49685612/
我是一名优秀的程序员,十分优秀!