Permalink
Browse files

Handle SIGINT properly.

  • Loading branch information...
1 parent 0d114af commit b048b2d55daa5039ebeeb55e411778c13a89828a @zharf zharf committed with Tilman Sauerbeck Sep 28, 2008
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/xmms2-scrobbler.c
View
@@ -30,6 +30,7 @@
#include <xmmsclient/xmmsclient.h>
#include <pthread.h>
#include <curl/curl.h>
+#include <signal.h>
#include "queue.h"
#include "submission.h"
#include "md5.h"
@@ -57,6 +58,15 @@ static bool need_handshake = true;
static bool shutdown_thread = false;
static bool keep_running = true;
+static struct sigaction sig;
+
+static void
+signal_handler (int sig)
+{
+ if (sig == SIGINT)
+ keep_running = false;
+}
+
static size_t
handle_handshake_reponse (void *rawptr, size_t size, size_t nmemb,
void *data)
@@ -677,6 +687,9 @@ main (int argc, char **argv)
pthread_t thread;
int s;
+ sig.sa_handler = &signal_handler;
+ sigaction (SIGINT, &sig, 0);
+
if (!load_config ())
return EXIT_FAILURE;

0 comments on commit b048b2d

Please sign in to comment.