Bug 73479

Summary: paplay incorrectly assumes stdin will be open
Product: PulseAudio Reporter: Simon Gomizelj <simongmzlj>
Component: toolsAssignee: pulseaudio-bugs
Status: RESOLVED MOVED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: lowest CC: lennart
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Simon Gomizelj 2014-01-10 16:45:02 UTC
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.
Comment 1 GitLab Migration User 2018-07-30 09:36:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/43.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.