--- a/sc2src/sc2mpd.cpp
+++ b/sc2src/sc2mpd.cpp
@@ -54,6 +54,7 @@
#include <vector>
#include <stdio.h>
#include <iostream>
+#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -96,6 +97,11 @@
#endif
+bool g_quitrequest = false;
+void sigcatcher(int)
+{
+ g_quitrequest = true;
+}
using namespace OpenHome;
using namespace OpenHome::Net;
@@ -555,6 +561,9 @@
Debug::SetLevel(Debug::kMedia);
+ signal(SIGINT, sigcatcher);
+ signal(SIGTERM, sigcatcher);
+
if (optionInteract.Value()) {
printf("q = quit\n");
for (;;) {
@@ -574,6 +583,10 @@
} else {
receiver->Play(uri);
for (;;) {
+ if (g_quitrequest) {
+ LOGDEB("Quit requested\n");
+ break;
+ }
sleep(1000);
}
}
@@ -585,5 +598,7 @@
if (optionInteract.Value())
printf("\n");
+ LOGDEB("EXIT\n");
+
return (0);
}