From 57e862712a9235c81f7cb28cf1b6e33e41e82e1b Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Sun, 9 Feb 2014 22:58:14 +0100
Subject: [PATCH 1/4] configure.ac: prepare for 0.18.9

---
 NEWS         | 2 ++
 configure.ac | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 066e12792..d04efbc73 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+ver 0.18.9 (not yet released)
+
 ver 0.18.8 (2014/02/07)
 * decoder
   - ffmpeg: support libav v10_alpha1
diff --git a/configure.ac b/configure.ac
index 301c3a033..6b14a695c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ(2.60)
 
-AC_INIT(mpd, 0.18.8, mpd-devel@musicpd.org)
+AC_INIT(mpd, 0.18.9, mpd-devel@musicpd.org)
 
 VERSION_MAJOR=0
 VERSION_MINOR=18

From 5d87a274a5cc30741d9e483fa189cbeb3c6087ba Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Mon, 17 Feb 2014 19:42:38 +0100
Subject: [PATCH 2/4] configure.ac: link the Vorbis encoder with libogg

Fixes another linker failure.  Similar to commit ea406875
---
 NEWS         | 2 ++
 configure.ac | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index d04efbc73..f671b1e75 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 ver 0.18.9 (not yet released)
+* encoder
+  - vorbis: fix another linker failure
 
 ver 0.18.8 (2014/02/07)
 * decoder
diff --git a/configure.ac b/configure.ac
index 6b14a695c..471504527 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1139,7 +1139,7 @@ fi
 AM_CONDITIONAL(ENABLE_FLAC_ENCODER, test x$enable_flac_encoder = xyes)
 
 dnl ---------------------------- Ogg Vorbis Encoder ---------------------------
-MPD_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis],
+MPD_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
 	[Ogg Vorbis encoder], [libvorbisenc not found])
 
 if test x$enable_vorbis_encoder = xyes; then

From 7fee85c80ab5e0bf16f26e353a32026144dae6a4 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Tue, 18 Feb 2014 18:39:19 +0100
Subject: [PATCH 3/4] configure.ac: fix linker failure when libvorbis/libogg
 are static

Link libvorbisfile first, followed to libvorbis and finally libogg.
This order is necessary because libvorbisfile depends on libvorbis.
---
 NEWS         | 2 ++
 configure.ac | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index f671b1e75..f12530e60 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 ver 0.18.9 (not yet released)
+* decoder
+  - vorbis: fix linker failure when libvorbis/libogg are static
 * encoder
   - vorbis: fix another linker failure
 
diff --git a/configure.ac b/configure.ac
index 471504527..81bdcea24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1023,7 +1023,7 @@ if test x$enable_tremor = xyes; then
 	fi
 fi
 
-MPD_AUTO_PKG(vorbis, VORBIS, [vorbis vorbisfile ogg],
+MPD_AUTO_PKG(vorbis, VORBIS, [vorbisfile vorbis ogg],
 	[Ogg Vorbis decoder], [libvorbis not found])
 if test x$enable_vorbis = xyes; then
 	AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])

From 5e1e92626c1e07834eb6cdb3d57623c30bf50212 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Tue, 18 Feb 2014 19:13:50 +0100
Subject: [PATCH 4/4] event/SignalMonitor: unblock signals after fork

Fixes hanging child process in the "pipe" output plugin.
---
 NEWS                        |  2 ++
 src/event/SignalMonitor.cxx | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index f12530e60..df6b14373 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ ver 0.18.9 (not yet released)
   - vorbis: fix linker failure when libvorbis/libogg are static
 * encoder
   - vorbis: fix another linker failure
+* output
+  - pipe: fix hanging child process due to blocked signals
 
 ver 0.18.8 (2014/02/07)
 * decoder
diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx
index 8c8527a77..eda52aba1 100644
--- a/src/event/SignalMonitor.cxx
+++ b/src/event/SignalMonitor.cxx
@@ -39,6 +39,10 @@
 
 #include <algorithm>
 
+#ifdef USE_SIGNALFD
+#include <pthread.h>
+#endif
+
 class SignalMonitor final : private SocketMonitor {
 #ifdef USE_SIGNALFD
 	SignalFD fd;
@@ -99,7 +103,21 @@ static std::atomic_bool signal_pending[MAX_SIGNAL];
 
 static Manual<SignalMonitor> monitor;
 
-#ifndef USE_SIGNALFD
+#ifdef USE_SIGNALFD
+
+/**
+ * This is a pthread_atfork() callback that unblocks the signals that
+ * were blocked for our signalfd().  Without this, our child processes
+ * would inherit the blocked signals.
+ */
+static void
+at_fork_child()
+{
+	sigprocmask(SIG_UNBLOCK, &signal_mask, nullptr);
+}
+
+#else
+
 static void
 SignalCallback(int signo)
 {
@@ -108,6 +126,7 @@ SignalCallback(int signo)
 	if (!signal_pending[signo].exchange(true))
 		monitor->WakeUp();
 }
+
 #endif
 
 void
@@ -115,6 +134,8 @@ SignalMonitorInit(EventLoop &loop)
 {
 #ifdef USE_SIGNALFD
 	sigemptyset(&signal_mask);
+
+	pthread_atfork(nullptr, nullptr, at_fork_child);
 #endif
 
 	monitor.Construct(loop);