From e5cade617627dd50cd39d341cc7764fc8809b5c9 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 7 Dec 2010 15:40:32 +0100 Subject: Bug #590245 - 'evolution --force-shutdown' should kill factories --- shell/killev.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'shell/killev.c') diff --git a/shell/killev.c b/shell/killev.c index 16849eec42..948523dccb 100644 --- a/shell/killev.c +++ b/shell/killev.c @@ -94,6 +94,18 @@ exit: return success; } +static void +kill_factories (void) +{ + #ifdef KILL_PROCESS_CMD + + system (KILL_PROCESS_CMD " -QUIT evolution 2> /dev/null"); + system (KILL_PROCESS_CMD " -QUIT e-calendar-factory 2> /dev/null"); + system (KILL_PROCESS_CMD " -QUIT e-addressbook-factory 2> /dev/null"); + + #endif +} + gint main (gint argc, gchar **argv) { @@ -116,17 +128,27 @@ main (gint argc, gchar **argv) if (!get_evolution_pid (pid_file)) { g_printerr ("Could not find Evolution's process ID\n"); + kill_factories (); exit (EXIT_FAILURE); } - /* Play it safe here and bail if something goes wrong. We don't - * want to just skip to the killing if we can't ask Evolution to - * terminate gracefully. Despite our name we actually want to - * -avoid- killing Evolution if at all possible. */ - if (!g_spawn_command_line_async ("evolution --quit", &error)) { - g_printerr ("%s", error->message); - g_error_free (error); - exit (EXIT_FAILURE); + if (g_getenv ("DISPLAY") == NULL) { + #ifdef KILL_PROCESS_CMD + + system (KILL_PROCESS_CMD " -QUIT evolution 2> /dev/null"); + + #endif + } else { + /* Play it safe here and bail if something goes wrong. We don't + * want to just skip to the killing if we can't ask Evolution to + * terminate gracefully. Despite our name we actually want to + * -avoid- killing Evolution if at all possible. */ + if (!g_spawn_command_line_async ("evolution --quit", &error)) { + g_printerr ("%s", error->message); + g_error_free (error); + kill_factories (); + exit (EXIT_FAILURE); + } } /* Now we set up a monitor on Evolution's .running file. @@ -136,6 +158,7 @@ main (gint argc, gchar **argv) if (error != NULL) { g_printerr ("%s", error->message); g_error_free (error); + kill_factories (); exit (EXIT_FAILURE); } @@ -155,5 +178,7 @@ main (gint argc, gchar **argv) g_object_unref (monitor); + kill_factories (); + return EXIT_SUCCESS; } -- cgit v1.2.3