脚本在读取stdout时卡住,不再继续执行,也不发生终止
import subprocess
p = subprocess.Popen(["mplayer", "-slave", "-quiet", "/home/pi/Music/爱的翅膀.mp3"], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = False)
p.stdin.write('\n')
print p.stdout.read() //此处
p.stdin.write('get_time_pos\n')
print p.stdout.read()
mplayer播放時會向stout輸入大量字符,超過了4096造成死鎖,輸出資訊不在我的需求之中,因此決定修改
stdout=open("/dev/null","w")
,解決問題。參考部落格http://blog.csdn.net/imzoer/a...