gnome-session r4956 - in trunk: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4956 - in trunk: . gnome-session
- Date: Fri, 15 Aug 2008 15:15:12 +0000 (UTC)
Author: mccann
Date: Fri Aug 15 15:15:11 2008
New Revision: 4956
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4956&view=rev
Log:
2008-08-15 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-app.h:
* gnome-session/gsm-autostart-app.c (_signal_pid),
(autostart_app_stop_spawn):
* gnome-session/gsm-manager.c (app_condition_changed):
Add support for killing apps. Try to stop app if
there isn't a client available for it.
Modified:
trunk/ChangeLog
trunk/gnome-session/gsm-app.h
trunk/gnome-session/gsm-autostart-app.c
trunk/gnome-session/gsm-manager.c
Modified: trunk/gnome-session/gsm-app.h
==============================================================================
--- trunk/gnome-session/gsm-app.h (original)
+++ trunk/gnome-session/gsm-app.h Fri Aug 15 15:15:11 2008
@@ -81,6 +81,7 @@
{
GSM_APP_ERROR_GENERAL = 0,
GSM_APP_ERROR_START,
+ GSM_APP_ERROR_STOP,
GSM_APP_NUM_ERRORS
} GsmAppError;
Modified: trunk/gnome-session/gsm-autostart-app.c
==============================================================================
--- trunk/gnome-session/gsm-autostart-app.c (original)
+++ trunk/gnome-session/gsm-autostart-app.c Fri Aug 15 15:15:11 2008
@@ -24,6 +24,8 @@
#include <ctype.h>
#include <string.h>
#include <sys/wait.h>
+#include <errno.h>
+
#include <glib.h>
#include <gio/gio.h>
@@ -667,10 +669,57 @@
}
}
+static int
+_signal_pid (int pid,
+ int signal)
+{
+ int status = -1;
+
+ /* perhaps block sigchld */
+ g_debug ("GsmAutostartApp: sending signal %d to process %d", signal, pid);
+ errno = 0;
+ status = kill (pid, signal);
+
+ if (status < 0) {
+ if (errno == ESRCH) {
+ g_warning ("Child process %d was already dead.",
+ (int)pid);
+ } else {
+ g_warning ("Couldn't kill child process %d: %s",
+ pid,
+ g_strerror (errno));
+ }
+ }
+
+ /* perhaps unblock sigchld */
+
+ return status;
+}
+
static gboolean
autostart_app_stop_spawn (GsmAutostartApp *app,
GError **error)
{
+ int res;
+
+ if (app->priv->pid < 1) {
+ g_set_error (error,
+ GSM_APP_ERROR,
+ GSM_APP_ERROR_STOP,
+ "Not running");
+ return FALSE;
+ }
+
+ res = _signal_pid (app->priv->pid, SIGTERM);
+ if (res != 0) {
+ g_set_error (error,
+ GSM_APP_ERROR,
+ GSM_APP_ERROR_STOP,
+ "Unable to stop: %s",
+ g_strerror (errno));
+ return FALSE;
+ }
+
return TRUE;
}
Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c (original)
+++ trunk/gnome-session/gsm-manager.c Fri Aug 15 15:15:11 2008
@@ -246,6 +246,8 @@
GError *error;
gboolean res;
+ g_debug ("GsmManager: starting app '%s'", gsm_app_peek_id (app));
+
error = NULL;
res = gsm_app_start (app, &error);
if (error != NULL) {
@@ -253,6 +255,8 @@
error->message);
g_error_free (error);
}
+ } else {
+ g_debug ("GsmManager: not starting - app still running '%s'", gsm_app_peek_id (app));
}
} else {
GError *error;
@@ -263,10 +267,22 @@
* be automatically restarted by adding the client to
* condition_clients */
manager->priv->condition_clients = g_slist_prepend (manager->priv->condition_clients, client);
+ g_debug ("GsmManager: stopping client %s for app", gsm_client_peek_id (client));
error = NULL;
res = gsm_client_stop (client, &error);
if (error != NULL) {
+ g_warning ("Not able to stop app client from its condition: %s",
+ error->message);
+ g_error_free (error);
+ }
+ } else {
+ g_debug ("GsmManager: stopping app %s", gsm_app_peek_id (app));
+
+ /* If we don't have a client then we should try to kill the app */
+ error = NULL;
+ res = gsm_app_stop (app, &error);
+ if (error != NULL) {
g_warning ("Not able to stop app from its condition: %s",
error->message);
g_error_free (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]