[MPlayer-users] How to properly terminate a looping mplayer

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Oct 19 11:03:11 CEST 2011


On Tue, Oct 18, 2011 at 10:50:28AM -0600, Deron Kazmaier wrote:
> Hi,
> 
> I wrote a fun little program that simple forks and runs mplayer,
> asking it to loop a video forever (-loop 0). I keep the pid, and
> when I detect a condition that requires the video to stop playing, I
> send mplayer a SIGTERM.
> 
> That is all fine and dandy and works just fine, except that there is
> about a 50:50 chance that the shell will be screwed up when the
> program that calls mplayer terminates and returns to the shell.
> Nothing I type will appear, but it does accept the input (this is
> via ssh) and pressing return will execute whatever I type and it
> will display the shell prompt but on the same line. I know, very
> odd.
> 
> So, the only thing I can think of is that SIGTERM mplayer caused
> some control code to be sent to stderr/stdout?
> 
> Before I simply pipe output/input to null, I want to make sure that
> I'm stopping mplayer in an acceptable way or should I be sending a
> different signal or passing something via input pipe.

The reason this happens in that MPlayer reconfigures the terminal
so it gets the key presses in a proper way.
If you don't actually control MPlayer that way, I think
-noconsolecontrols (some '-' in there somewhere I think) should
disable changing the mode.
In addition the terminal should be cleaned up just fine unless you
send _lots_ of SIGTERMs instead of just one or you sometimes
send a SIGKILL.
You could always send a quit command via a slave mode input pipe
though.


More information about the MPlayer-users mailing list