Closed EliteTK closed 7 years ago
For more context, this happens because (at least on Linux) open(2)
returns as its fd number the lowest unopened file descriptor number. The output process doesn't need stdin
; it reads all of its input from the master end of its pty. Therefore, it closes STDIN_FILENO
when it starts. This file descriptor may be reassigned to some other process. In the case of PulseAudio, it is assigned to the read-end of a pipe between the Pulse client and server. Pulse then does some assert
s on the sanity of its pipes, which fail, because the read side is closed.
In fact, it is a bug for outputproc to be closing this FD before exit.
outputproc already closes stdin before going into its poll loop, this means that when the SIGCHLD handler closes stdin for subchild, it ends up closing an already closed fd.
Additionally, on my system using pulseaudio, this was closing the read end of an internal pulseaudio pipe causing a stacktrace on exit. This fixes #25.