summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Marcus Clarke <marcus@freebsd.org>2008-10-22 03:35:48 +0000
committerThomas James Alexander Thurman <tthurman@src.gnome.org>2008-10-22 03:35:48 +0000
commit1866268c94c43ba5f64b7b218c59e37c56770a8e (patch)
tree344acf7075936217bf3dbdce96833e6651f03dc3
parentb7ee7bdd9ba9a6a786a3496582b9ee1c5b24c76e (diff)
downloadmetacity-1866268c94c43ba5f64b7b218c59e37c56770a8e.tar.gz
metacity-1866268c94c43ba5f64b7b218c59e37c56770a8e.tar.bz2
new functions add sigterm_handler in case we receive a SIGTERM. Closes
2008-10-22 Joe Marcus Clarke <marcus@freebsd.org> * src/core/main.c (meta_finalize, sigterm_handler): new functions * src/core/main.c (main): add sigterm_handler in case we receive a SIGTERM. Closes #553980. svn path=/trunk/; revision=3974
-rw-r--r--ChangeLog6
-rw-r--r--src/core/main.c31
2 files changed, 31 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d5171f..459df77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-22 Joe Marcus Clarke <marcus@freebsd.org>
+
+ * src/core/main.c (meta_finalize, sigterm_handler): new functions
+ * src/core/main.c (main): add sigterm_handler in case we receive
+ a SIGTERM. Closes #553980.
+
2008-10-22 Matthew Martin <mtt.martin@gmail.com>
* src/core/window.c (meta_window_set_demands_attention): minimised
diff --git a/src/core/main.c b/src/core/main.c
index 3d7706a..173be28 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -323,8 +323,8 @@ meta_parse_options (int *argc, char ***argv,
* try to use the environment variable METACITY_DISPLAY. If that
* also is NULL, use the default - :0.0
*/
-static
-void meta_select_display (gchar *display_name)
+static void
+meta_select_display (gchar *display_name)
{
gchar *envVar = "";
if (display_name)
@@ -335,6 +335,23 @@ void meta_select_display (gchar *display_name)
/* DO NOT FREE envVar, putenv() sucks */
putenv (envVar);
}
+
+static void
+meta_finalize (void)
+{
+ meta_display_close (meta_get_display (),
+ CurrentTime); /* I doubt correct timestamps matter here */
+
+ meta_session_shutdown ();
+}
+
+static void
+sigterm_handler (int signum)
+{
+ meta_finalize ();
+
+ exit (meta_exit_code);
+}
/**
* This is where the story begins. It parses commandline options and
@@ -375,6 +392,11 @@ main (int argc, char **argv)
g_strerror (errno));
#endif
+ act.sa_handler = &sigterm_handler;
+ if (sigaction (SIGTERM, &act, NULL) < 0)
+ g_printerr ("Failed to register SIGTERM handler: %s\n",
+ g_strerror (errno));
+
if (g_getenv ("METACITY_VERBOSE"))
meta_set_verbose (TRUE);
if (g_getenv ("METACITY_DEBUG"))
@@ -504,11 +526,8 @@ main (int argc, char **argv)
g_main_loop_run (meta_main_loop);
- meta_display_close (meta_get_display (),
- CurrentTime); /* I doubt correct timestamps matter here */
+ meta_finalize ();
- meta_session_shutdown ();
-
if (meta_restart_after_quit)
{
GError *err;