paplay incorrectly assumes stdin will be open
Submitted by Simon Gomizelj
Assigned to pul..@..op.org
Description
I ran into this issue after debuging why paplay wouldn't work in a script called by another program. It looks like this program closes stdin/stdout/stderr before running the script. This causes this to happen:
open("foo.wav", O_RDONLY|O_NOCTTY|O_CLOEXEC) = 0 fcntl(0, F_GETFD) = 0x1 (flags FD_CLOEXEC) dup2(0, 0) = 0 close(0) = 0 fstat(0, 0x7fffaa2ce740) = -1 EBADF (Bad file descriptor)
Open returns 0, as it should, in this case. However the assumption that stdin is still present causes the dup2/close syscalls to close the filedescriptor we've just opened and not stdin as intended. This causes paplay to die with a EBADF error.