当前位置: 技术问答>linux和unix
tcgetattr(STDIN_FILENO,&term)后term中值的含义
来源: 互联网 发布时间:2016-06-23
本文导语: 小弟初学LINUX,看到终端I/O那章,自己写了下面一段代码 int main(void) { struct termios term; tcgetattr(STDIN_FILENO,&term); exit(0); } 然后用gdb停在exit前面,print term后得到下面一串内容: (gdb) print...
小弟初学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 '',
c_cc = "033417725040001002123320022172726", '' , c_ispeed = 15, c_ospeed = 15}
怎么标记位的值都是数字啊?不应该是英文标志的吗?数字代表什么意思呢
那个c_cc中的数字又代表什么呢? 菜鸟问题,哪位大哥帮忙解答下哈
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 '',
c_cc = "033417725040001002123320022172726", '' , c_ispeed = 15, c_ospeed = 15}
怎么标记位的值都是数字啊?不应该是英文标志的吗?数字代表什么意思呢
那个c_cc中的数字又代表什么呢? 菜鸟问题,哪位大哥帮忙解答下哈
|
打开/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 */
注意,不同的系统数值可能是不同的
比如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 */
注意,不同的系统数值可能是不同的