linux stty命令學習 stty命令用來修改和顯示終端行設定。 sh-# sttyspeed 115200 baud; line = 0;kill = ^X;-brkint ixany -imaxbel-iexten -echoe echoprtsh-# stty -aspeed 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 -iutf8opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0isig icanon -iexten echo -echoe echok -echonl -noflsh -xcase -tostop echoprtechoctl 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 pssh-# 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