#include <assert.h>
#ifdef WIN32
-#include <windows.h>
+# include <windows.h>
#endif
#include <shairplay/dnssd.h>
static int running;
+#ifndef WIN32
+
+#include <signal.h>
+static void
+signal_handler(int sig)
+{
+ switch (sig) {
+ case SIGINT:
+ case SIGTERM:
+ running = 0;
+ break;
+ }
+}
+static void
+init_signals(void)
+{
+ struct sigaction sigact;
+
+ sigact.sa_handler = signal_handler;
+ sigemptyset(&sigact.sa_mask);
+ sigact.sa_flags = 0;
+ sigaction(SIGINT, &sigact, NULL);
+ sigaction(SIGTERM, &sigact, NULL);
+}
+
+#endif
+
static ao_device *
audio_open_device(shairplay_options_t *opt, int bits, int channels, int samplerate)
int error;
+#ifndef WIN32
+ init_signals();
+#endif
+
memset(&options, 0, sizeof(options));
if (parse_options(&options, argc, argv)) {
return 0;