dhobsd / castty

A CLI tool to record audio-enabled screencasts of your terminal, for the web.
Other
117 stars 15 forks source link

castty: Don't close stdin of subchild on SIGCHLD (fixes #25) #26

Closed EliteTK closed 7 years ago

EliteTK commented 7 years ago

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.

dhobsd commented 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 asserts 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.