$ git clone http://tcclient.ion.nu/tc_client.git
commit 070e13059e14f81359c79a87096dd7c5d4d619e5
Author: Alicia <...>
Date:   Thu Nov 17 12:49:03 2016 +0100

    tc_client-gtk: handle failure to connect to pulseaudio more gracefully.

diff --git a/ChangeLog b/ChangeLog
index 1589708..79884c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ tc_client-gtk: install the camera placeholder animation for the 'install' target
 tc_client-gtk: mark outgoing video keyframes as keyframes.
 tc_client-gtk: added options for making links blue and how to wrap lines.
 tc_client-gtk: added volume indicators.
+tc_client-gtk: handle failure to connect to pulseaudio more gracefully.
 dist/appimage.sh: fix audio in appimages by building ffmpeg with support for nellymoser and speex, and depending on the system's libao and libpulse instead of including it in the appimage.
 libcamera(escapi): handle failure to open camera more gracefully.
 0.40:
diff --git a/utilities/gtk/camviewer.c b/utilities/gtk/camviewer.c
index 356646e..39555dd 100644
--- a/utilities/gtk/camviewer.c
+++ b/utilities/gtk/camviewer.c
@@ -939,6 +939,8 @@ void captcha_done(GtkWidget* button, void* x)
   write(tc_client_in[1], "\n", 1);
 }
 
+void justwait(int x){wait(0);}
+
 int main(int argc, char** argv)
 {
   if(!strncmp(argv[0], "./", 2)){frombuild=1;}
@@ -948,7 +950,7 @@ int main(int argc, char** argv)
   data->vdecoder=avcodec_find_decoder(AV_CODEC_ID_FLV1);
   data->vencoder=avcodec_find_encoder(AV_CODEC_ID_FLV1);
 #ifndef _WIN32
-  signal(SIGCHLD, SIG_IGN);
+  signal(SIGCHLD, justwait); // SIG_IGN causes trouble with libpulse's autospawn
 #else
   frombuild=1;
 #endif
diff --git a/utilities/gtk/media.c b/utilities/gtk/media.c
index 95179fb..85f2cc5 100644
--- a/utilities/gtk/media.c
+++ b/utilities/gtk/media.c
@@ -546,6 +546,7 @@ GdkPixbuf* scaled_gdk_pixbuf_from_cam(CAM* cam, unsigned int width, unsigned int
 }
 
 #ifdef HAVE_PULSEAUDIO
+extern void justwait(int);
 void* audiothread_in(void* fdp)
 {
   int fd=*(int*)fdp;
@@ -554,7 +555,10 @@ void* audiothread_in(void* fdp)
   pulsespec.format=PA_SAMPLE_FLOAT32;
   pulsespec.channels=1;
   pulsespec.rate=44100;
+  signal(SIGCHLD, SIG_DFL); // Briefly revert to the default handler to not break pulseaudio's autospawn feature
   pulse=pa_simple_new(0, "tc_client-gtk", PA_STREAM_RECORD, 0, "mic", &pulsespec, 0, 0, 0);
+  signal(SIGCHLD, justwait);
+  if(!pulse){return 0;}
   char buf[1024];
   // Just read/listen and write to the main thread until either reading/listening or writing fails
   while(1)