Should not read standard input if not on a terminal
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mplayer (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: mplayer
Running mplayer in a loop is impossible because it consumes standard input even when invoked just to batch convert a file.
Consider a script like:
find . -type f |
while read file; do
echo "# $file"
mplayer -vc null -vo null -ao pcm:file=
done
This will fail mysteriously with "No bind found for key 'O'" warnings etc because apparently mplayer is eating some of the output from the find command as if the user were using it interactively and pressing keys to resize the display etc. As an additional symptom, the output from the echo will mysteriously have chopped file names.
As a workaround, the small sample script above can be fixed by adding a redirection </dev/null to the mplayer command line. Constructing the loop differently (e.g. to run mplayer from within find with -exec) is another possible workaround.
There are several threads about this in Google but none I have found actually correctly diagnosed and corrected this problem.
There is a simple ioctl to find out when a program is invoked with standard input connected to a terminal; the "test -t 0" command does this in a shell script. mplayer should leave standard input alone if it is not connected to a terminal.
era@fsopti607:~$ lsb_release -rd
Description: Ubuntu 10.04.1 LTS
Release: 10.04
era@fsopti607:~$ apt-cache policy mplayer
mplayer:
Installed: 2:1.0~rc3+
Candidate: 2:1.0~rc3+
Version table:
*** 2:1.0~rc3+
500 http://
100 /var/lib/
2:
500 http://