請與我一起裸露,這個問題有一些設置。如何在ZSH中啓動`less`與啓動`cat`有什麼不同?關於使用備用屏幕和背景懸置
在我的操作系統上,默認情況下,ZSH有-tostop
(或者是tty?)。
這允許後臺進程在輸出時輸出到shell。
因此:
> stty -tostop
> echo 'random' >/tmp/random
> cat /tmp/random &
[1] 7588
random
[1] + 7588 done cat /tmp/random
相應:
> stty tostop
> echo 'random' >/tmp/random
> cat /tmp/random &
[1] 3888
[1] + 3888 suspended (tty output) cat /tmp/random
閱讀此說明書和經驗中,我發現,ZSH有4種類型的掛起的進程(可以通過使用kill -$SIGNAL $PID ; jobs
看到這一點)的:
job state - signal that gives you job state
suspended - SIGTSTP
suspended (signal) - SIGSTOP
suspended (tty input) - SIGTTIN
suspended (tty output) - SIGTTOU
這意味着3888
進程正在接收SIGTTOU信號。
這一切都有道理。
現在我的問題是,爲什麼less
不受stty tostop
或stty -tostop
的影響?
> stty tostop
> less /tmp/random &
[1] 6300
[1] + 6300 suspended (tty output) less --LONG-PROMPT --chop-long-lines /tmp/random
> stty -tostop
> less /tmp/random &
[1] 4808
[1] + 4808 suspended (tty output) less --LONG-PROMPT --chop-long-lines /tmp/random
正如你可以在這兩種情況下看到,less
總是被停用的背景。
現在,我知道less -X
,我也知道終端仿真器具有的備用屏幕功能。 事實上,你可以用less -X
運行上面的2個命令,並且它會導致相同類型的暫停。儘管-X
使它不使用替代屏幕,但更少仍然得到suspended (tty output)
!
我想知道是如何less
總是被停用與suspended (tty output)
,即使tostop
是越來越切換,即使-X
被觸發過的實際機制。除非有其他方式less
被掛起,否則shell如何始終發送SIGTTOU
到less
。
交替屏幕與'less'中的信號處理無關。 –