tcgetattr(STDIN_FILENO,&term)后term中值的含义

guan323333 2009-08-12 02:40:05
小弟初学LINUX,看到终端I/O那章,自己写了下面一段代码

int main(void)
{
struct termios term;
tcgetattr(STDIN_FILENO,&term);
exit(0);

}
然后用gdb停在exit前面,print term后得到下面一串内容:
(gdb) print term
$1 = {c_iflag = 1280, c_oflag = 5, c_cflag = 191, c_lflag = 35387, c_line = 0 '\0',
c_cc = "\003\034\177\025\004\000\001\000\021\023\032\000\022\017\027\026", '\0' <repeats 15 times>, c_ispeed = 15, c_ospeed = 15}

怎么标记位的值都是数字啊?不应该是英文标志的吗?数字代表什么意思呢
那个c_cc中的数字又代表什么呢? 菜鸟问题,哪位大哥帮忙解答下哈
...全文
51 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dugu_ke 2009-08-13
  • 打赏
  • 举报
回复
打开/usr/include/termios.h查看定义:
比如c_iflag的值
C/C++ code
/*
* Input flags - software input processing
*/
#define IGNBRK 0x00000001 /* ignore BREAK condition */
#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
#define PARMRK 0x00000008 /* mark parity and framing errors */
#define INPCK 0x00000010 /* enable checking of parity errors */
#define ISTRIP 0x00000020 /* strip 8th bit off chars */
#define INLCR 0x00000040 /* map NL into CR */
#define IGNCR 0x00000080 /* ignore CR */
#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
#define IXON 0x00000200 /* enable output flow control */
#define IXOFF 0x00000400 /* enable input flow control */
#ifndef _POSIX_SOURCE
#define IXANY 0x00000800 /* any char will restart after stop */
#define IMAXBEL 0x00002000 /* ring bell on input queue full */


注意,不同的系统数值可能是不同的

23,114

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧