[phodav: 4/14] spice-unix: handle SIGINT properly
- From: Marc-André Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [phodav: 4/14] spice-unix: handle SIGINT properly
- Date: Wed, 29 May 2019 12:49:15 +0000 (UTC)
commit 2694cbab62178a145ef8dd5476b0e17116d0f691
Author: Jakub Janků <jjanku redhat com>
Date: Fri May 24 19:16:35 2019 +0200
spice-unix: handle SIGINT properly
On Unix, GLib provides a safer way to handle signals
that should not be prone to reentrancy, so let's use it.
Signed-off-by: Jakub Janků <jjanku redhat com>
spice/spice-webdavd.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 023996a..674a582 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -24,6 +24,7 @@
#include <gio/gunixoutputstream.h>
#include <fcntl.h>
#include <glib/gstdio.h>
+#include <glib-unix.h>
#endif
#ifdef G_OS_WIN32
@@ -245,6 +246,15 @@ quit (int sig)
g_main_loop_quit (loop);
}
+#ifdef G_OS_UNIX
+static gboolean
+signal_handler (gpointer user_data)
+{
+ quit(SIGINT);
+ return G_SOURCE_REMOVE;
+}
+#endif
+
static Client *
add_client (GSocketConnection *client_connection)
{
@@ -1109,7 +1119,11 @@ main (int argc, char *argv[])
}
g_option_context_free (opts);
+#ifdef G_OS_UNIX
+ g_unix_signal_add (SIGINT, signal_handler, NULL);
+#else
signal (SIGINT, quit);
+#endif
/* run socket service once at beginning, there seems to be a bug on
windows, and it can't accept new connections if cleanup and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]