linux stty命令学习


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
 

相关内容

    暂无相关文章