From 4ebd3a09a6979bc568459aea842f09d12f4ad4f2 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 15 Jul 2014 00:13:28 +0530 Subject: main: Add SIGINT handler --- src/lib.c | 7 ++++--- src/main.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib.c b/src/lib.c index 5816b4e..bb076f6 100644 --- a/src/lib.c +++ b/src/lib.c @@ -59,9 +59,10 @@ stp_on_gst_bus_message (GstBus *bus, return TRUE; } -gboolean stp_unref_gst_buffer (GstBuffer **buffer, - guint idx, - gpointer user_data) +gboolean +stp_unref_gst_buffer (GstBuffer **buffer, + guint idx, + gpointer user_data) { gst_buffer_unref (*buffer); *buffer = NULL; diff --git a/src/main.c b/src/main.c index 2beca56..6e61c3e 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include "lib.h" #include "encode.h" @@ -701,6 +703,13 @@ GET: } } +gboolean +exit_on_signal_cb (SoupServer *server) +{ + soup_server_quit (server); + return G_SOURCE_REMOVE; +} + int main (int argc, char *argv[]) @@ -740,6 +749,7 @@ main (int argc, G_CALLBACK (request_finished_cb), ctx_table); g_signal_connect (server, "request-aborted", G_CALLBACK (request_aborted_cb), ctx_table); + g_unix_signal_add (SIGINT, (GSourceFunc)exit_on_signal_cb, server); soup_server_run (server); return 0; -- cgit v0.11.2-2-gd1dd