
當我透過 ssh 運行命令時iostat -dkx 2 2
,我得到了預期的結果,但本地電腦上的進程在「可中斷睡眠」狀態下處於活動狀態。為什麼會發生這種情況?有沒有辦法找出該行為的原因?
完整命令:
$ ssh -o ConnectTimeout=4 -o ChallengeResponseAuthentication=no -o PasswordAuthentication=no <user>@host> iostat -dkx 2 2
ps輸出:
$ ps aux | grep 11893 && ps aux | grep PID
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1000 10273 0.0 0.0 103280 904 pts/0 S+ 12:09 0:00 grep PID
1000 11893 0.0 0.0 158732 3892 ? S Feb17 0:00 ssh -o ConnectTimeout=4 -o ChallengeResponseAuthentication=no -o PasswordAuthentication=no <user>@<host> iostat -dkx 2 2
1000 10285 0.0 0.0 103280 904 pts/0 S+ 12:09 0:00 grep 11893
跟蹤:
$ strace -p 11893
Process 11893 attached - interrupt to quit
select(8, [5], [], NULL, NULL^C <unfinished ...>
哇:
$ cat /proc/11893/wchan
poll_schedule_timeout
堆疊追蹤:
$ cat /proc/11893/stack
[] poll_schedule_timeout+0x39/0x60
[] do_select+0x6bb/0x7c0
[] core_sys_select+0x18a/0x2c0
[] sys_select+0x47/0x110
[] system_call_fastpath+0x16/0x1b
[] 0xffffffffffffffff
答案1
似乎沒有什麼問題。您正在查看的進程(ssh)在您獲取其進程統計資料時根本沒有任何關係。
只要遠端啟動的命令沒有輸出,「select」就會阻塞,進程就會進入睡眠狀態。
答案2
ControlMaster
您的配置中有( )嗎~/.ssh/config
?如果這樣做,並且該ssh
進程是另一個連接的主連接,則該進程將無法退出。如果這是問題所在,則它與 running 無關iostat
,保持開啟狀態的連線是您在沒有連線處於活動狀態時與此特定伺服器建立的第一個連線。