gnome-settings-daemon r635 - in trunk: . gnome-settings-daemon
- From: halfline svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r635 - in trunk: . gnome-settings-daemon
- Date: Wed, 17 Dec 2008 16:09:24 +0000 (UTC)
Author: halfline
Date: Wed Dec 17 16:09:23 2008
New Revision: 635
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=635&view=rev
Log:
2008-12-07 Ray Strode <rstrode redhat com>
Shutdown properly when killed.
* gnome-settings-daemon/main.c (on_term_signal):
top half of signal handling code. close a pipe
when getting SIGTERM.
(on_term_signal_pipe_closed),
(watch_for_term_signal),
(set_session_over_handler): bottom half. Quit
event loop when term pipe gets closed.
Modified:
trunk/ChangeLog
trunk/gnome-settings-daemon/main.c
Modified: trunk/gnome-settings-daemon/main.c
==============================================================================
--- trunk/gnome-settings-daemon/main.c (original)
+++ trunk/gnome-settings-daemon/main.c Wed Dec 17 16:09:23 2008
@@ -48,6 +48,7 @@
static gboolean no_daemon = FALSE;
static gboolean debug = FALSE;
static int daemon_pipe_fds[2];
+static int term_signal_pipe_fds[2];
static GOptionEntry entries[] = {
{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -177,6 +178,54 @@
}
static void
+on_term_signal (int signal)
+{
+ /* Wake up main loop to tell it to shutdown */
+ close (term_signal_pipe_fds[1]);
+ term_signal_pipe_fds[1] = -1;
+}
+
+static gboolean
+on_term_signal_pipe_closed (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data)
+{
+ GnomeSettingsManager *manager;
+
+ manager = GNOME_SETTINGS_MANAGER (data);
+
+ term_signal_pipe_fds[0] = -1;
+
+ /* Got SIGTERM, time to clean up and get out
+ */
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+watch_for_term_signal (GnomeSettingsManager *manager)
+{
+ GIOChannel *channel;
+
+ if (-1 == pipe (term_signal_pipe_fds) ||
+ -1 == fcntl (term_signal_pipe_fds[0], F_SETFD, FD_CLOEXEC) ||
+ -1 == fcntl (term_signal_pipe_fds[1], F_SETFD, FD_CLOEXEC)) {
+ g_error ("Could not create pipe: %s", g_strerror (errno));
+ exit (EXIT_FAILURE);
+ }
+
+ channel = g_io_channel_unix_new (term_signal_pipe_fds[0]);
+ g_io_channel_set_encoding (channel, NULL, NULL);
+ g_io_channel_set_buffered (channel, FALSE);
+ g_io_add_watch (channel, G_IO_HUP, on_term_signal_pipe_closed, manager);
+ g_io_channel_unref (channel);
+
+ signal (SIGTERM, on_term_signal);
+
+}
+
+static void
set_session_over_handler (DBusGConnection *bus, GnomeSettingsManager *manager)
{
DBusGProxy *session_proxy;
@@ -206,6 +255,7 @@
manager,
NULL);
+ watch_for_term_signal (manager);
gnome_settings_profile_end (NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]