A lot of people said: ctrl+s stop/pause only the terminal output, not the program. But today, I have opened in terminal a movie
mplayer mymovie.mkv
Movie start to play, after I press ctrl+S
movie stop, and resume(using the mouse wheel) only after pressing ctrl+q
Why this happen if ctrl+s stop only terminal output as many people said? I have also tried xmms and ffplay using ctrl+s ctrl+q
ffplay file.mp3 # The video stop,the terminal output stop, the audio continue
xmms file.mp3 # The audio continue
答案1
It does stop just the TTY. However that has side effects that propagate down to the applications running in it.
Basically when you do Ctrl+S, the TTY stops reading data from the file descriptor the programs are connected to. This file descriptor is basically a pipe, which has a buffer on it. Thus programs which don't write a lot are able to continue operating for a short period while the TTY isn't reading. But as soon as that buffer fills up, any application which tries to write to it is going to end up blocking and hang.
I don't know the details of ffplay
, but I suspect this is what's happening. If it renders some sort of progress bar or status to the terminal, this can fill up that buffer very fast.
The reason why the audio might continue while video does not is likely due to threading. Only the thread which writes to the TTY is going to end up blocking. Other threads can continue. So if the thread that handles video is also the one writing to the TTY, or if it needs something from the thread that is writing to the TTY, it will hang.