Should not read standard input if not on a terminal

Bug #697655 reported by era
6
This bug affects 1 person
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="$file.wav" "$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+svn20090426-1ubuntu16.1
  Candidate: 2:1.0~rc3+svn20090426-1ubuntu16.1
  Version table:
 *** 2:1.0~rc3+svn20090426-1ubuntu16.1 0
        500 http://mirrors.nic.funet.fi/ubuntu/ lucid-updates/multiverse Packages
        100 /var/lib/dpkg/status
     2:1.0~rc3+svn20090426-1ubuntu16 0
        500 http://mirrors.nic.funet.fi/ubuntu/ lucid/multiverse Packages

era (era)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.