summaryrefslogtreecommitdiff
path: root/daemon/session-worker-main.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2012-12-03 13:53:44 -0500
committerRay Strode <rstrode@redhat.com>2013-01-22 11:56:26 -0500
commit4952f6e5b023428e5f11f763531533c7b262f324 (patch)
tree00b6aaa89047436a07c336df9535eb5dc4b8304d /daemon/session-worker-main.c
parent59d705966a50fe796b5ba7414697aa503476a7ec (diff)
downloadgdm-4952f6e5b023428e5f11f763531533c7b262f324.tar.gz
Port to g_unix_signal_add(), drop GdmSignalHandler
The level of copy/paste going on here before is rather astonishing. For example, in some cases, I dropped spurious handling of SIGHUP, when the code didn't have any settings to reread. Anyways, the code is now clearer, and we get to drop all the bits of gdm-signal-handler.[ch] for the integrated GLib handling. https://bugzilla.gnome.org/show_bug.cgi?id=676181
Diffstat (limited to 'daemon/session-worker-main.c')
-rw-r--r--daemon/session-worker-main.c67
1 files changed, 14 insertions, 53 deletions
diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c
index 57027cf3..40cd08be 100644
--- a/daemon/session-worker-main.c
+++ b/daemon/session-worker-main.c
@@ -35,7 +35,6 @@
#include <glib/gi18n.h>
#include <glib-object.h>
-#include "gdm-signal-handler.h"
#include "gdm-common.h"
#include "gdm-log.h"
#include "gdm-session-worker.h"
@@ -47,51 +46,23 @@
static GdmSettings *settings = NULL;
static gboolean
-signal_cb (int signo,
- gpointer data)
+on_shutdown_signal_cb (gpointer user_data)
{
- int ret;
+ GMainLoop *mainloop = user_data;
- g_debug ("Got callback for signal %d", signo);
+ g_main_loop_quit (mainloop);
- ret = TRUE;
-
- switch (signo) {
- case SIGINT:
- case SIGTERM:
- /* let the fatal signals interrupt us */
- g_debug ("Caught signal %d, shutting down normally.", signo);
- ret = FALSE;
- break;
-
- case SIGHUP:
- g_debug ("Got HUP signal");
- /* FIXME:
- * Reread config stuff like system config files, VPN service files, etc
- */
- ret = TRUE;
-
- break;
-
- case SIGUSR1:
- g_debug ("Got USR1 signal");
- /* FIXME:
- * Play with log levels or something
- */
- ret = TRUE;
-
- gdm_log_toggle_debug ();
-
- break;
+ return FALSE;
+}
- default:
- g_debug ("Caught unhandled signal %d", signo);
- ret = TRUE;
+static gboolean
+on_sigusr1_cb (gpointer user_data)
+{
+ g_debug ("Got USR1 signal");
- break;
- }
+ gdm_log_toggle_debug ();
- return ret;
+ return TRUE;
}
static gboolean
@@ -115,7 +86,6 @@ main (int argc,
GMainLoop *main_loop;
GOptionContext *context;
GdmSessionWorker *worker;
- GdmSignalHandler *signal_handler;
const char *address;
gboolean is_for_reauth;
static GOptionEntry entries [] = {
@@ -161,13 +131,9 @@ main (int argc,
main_loop = g_main_loop_new (NULL, FALSE);
- signal_handler = gdm_signal_handler_new ();
- gdm_signal_handler_set_fatal_func (signal_handler,
- (GDestroyNotify)g_main_loop_quit,
- main_loop);
- gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
- gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
+ g_unix_signal_add (SIGTERM, on_shutdown_signal_cb, main_loop);
+ g_unix_signal_add (SIGINT, on_shutdown_signal_cb, main_loop);
+ g_unix_signal_add (SIGUSR1, on_sigusr1_cb, NULL);
g_main_loop_run (main_loop);
@@ -175,13 +141,8 @@ main (int argc,
g_object_unref (worker);
}
- if (signal_handler != NULL) {
- g_object_unref (signal_handler);
- }
-
g_main_loop_unref (main_loop);
-
g_debug ("Worker finished");
return 0;