linux stty命令学习

stty命令用来修改和显示终端行设置。

sh-# stty
speed 115200 baud; line = 0;
kill = ^X;
-brkint ixany -imaxbel
-iexten -echoe echoprt
sh-# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^X; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 1;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo -echoe echok -echonl -noflsh -xcase -tostop echoprt
echoctl echoke

CTRL+S,用来stop当前的shell;
CTRL+Q,用来start当前的shell;
CTRL+Z,用来suspend当前的shell;
CTRL+C,用来interrupt当前执行的程序;
...

这样我们终于知道了为什么在shell下键入组合键CTRL+C,CTRL+D,CTRL+Z会有对应的处理了。
原来是shell在运行时,它已经接管了对这些按键的处理了。

sh-# ps
PID TTY TIME CMD
409 ? 00:00:00 init
943 ? 00:00:00 sh
1213 ? 00:00:00 sh
4918 ? 00:00:00 ps
sh-# kill -2 943

sh-#
这里我们测试了一下给当前shell发送SIGINT signal,由于当前shell下没有运行任何命令或程序,
所以看起来什么都没做。
你也可以在shell下按组合键CTRL+C来看看,没错,CTRL+C实际上就是给当前shell发送SIGINT,
它们俩是等效的。

待解决问题:当我的终端类型为/dev/console时,在shell下按CTRL+S/CTRL+Q等组合键没有作用;
sh-# tty
/dev/console
但是当我的终端类型为/dev/pts/6时在shell下按CTRL+S/CTRL+Q会产生作用;
sh-# tty
/dev/pts/6
这是什么原因造成的?跟终端类型有关系吗?如何去确认?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值