--- live555MediaServer.cpp	2015-06-22 00:09:17.000000000 +0200
+++ live555MediaServer-patched.cpp	2015-06-24 10:47:48.322917645 +0200
@@ -20,8 +20,21 @@
 #include <BasicUsageEnvironment.hh>
 #include "DynamicRTSPServer.hh"
 #include "version.hh"
+#include <signal.h>
+#include <iostream>
+
+static char STOP_NOW = 0;
+
+void signalHandler(int sigNumber) {
+    
+    if (sigNumber == SIGINT) {
+        
+        STOP_NOW = 1;
+    }
+}
 
 int main(int argc, char** argv) {
+
   // Begin by setting up our usage environment:
   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
   UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
@@ -53,6 +66,15 @@
   *env << "\tversion " << MEDIA_SERVER_VERSION_STRING
        << " (LIVE555 Streaming Media library version "
        << LIVEMEDIA_LIBRARY_VERSION_STRING << ").\n";
+    
+  if (signal(SIGINT, signalHandler) == SIG_ERR) {
+        
+      *env << "SIGINT handler setup failure !\n";
+  }
+  else {
+        
+      *env << "SIGINT handler setup OK.\n";
+  }
 
   char* urlPrefix = rtspServer->rtspURLPrefix();
   *env << "Play streams from this server using the URL\n\t"
@@ -86,7 +108,9 @@
     *env << "(RTSP-over-HTTP tunneling is not available.)\n";
   }
 
-  env->taskScheduler().doEventLoop(); // does not return
+  env->taskScheduler().doEventLoop(&STOP_NOW); // does not return
 
+  Medium::close(rtspServer);
+  
   return 0; // only to prevent compiler warning
 }
