gnome-session r4739 - in branches/dbus_based: . gnome-session



Author: mccann
Date: Fri Jun 13 21:21:12 2008
New Revision: 4739
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4739&view=rev

Log:
2008-06-13  William Jon McCann  <jmccann redhat com>

	* gnome-session/gsm-app.c (gsm_app_class_init), (gsm_app_died):
	* gnome-session/gsm-app.h:
	* gnome-session/gsm-autostart-app.c (app_exited), (launch):
	Wait on processes so we don't create zombies.



Modified:
   branches/dbus_based/ChangeLog
   branches/dbus_based/gnome-session/gsm-app.c
   branches/dbus_based/gnome-session/gsm-app.h
   branches/dbus_based/gnome-session/gsm-autostart-app.c

Modified: branches/dbus_based/gnome-session/gsm-app.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-app.c	(original)
+++ branches/dbus_based/gnome-session/gsm-app.c	Fri Jun 13 21:21:12 2008
@@ -39,6 +39,7 @@
 
 enum {
         EXITED,
+        DIED,
         REGISTERED,
         LAST_SIGNAL
 };
@@ -176,6 +177,15 @@
                               g_cclosure_marshal_VOID__VOID,
                               G_TYPE_NONE,
                               0);
+        signals[DIED] =
+                g_signal_new ("died",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmAppClass, died),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
 
         signals[REGISTERED] =
                 g_signal_new ("registered",
@@ -290,3 +300,11 @@
 
         g_signal_emit (app, signals[EXITED], 0);
 }
+
+void
+gsm_app_died (GsmApp *app)
+{
+        g_return_if_fail (GSM_IS_APP (app));
+
+        g_signal_emit (app, signals[DIED], 0);
+}

Modified: branches/dbus_based/gnome-session/gsm-app.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-app.h	(original)
+++ branches/dbus_based/gnome-session/gsm-app.h	Fri Jun 13 21:21:12 2008
@@ -53,8 +53,8 @@
         GObjectClass parent_class;
 
         /* signals */
-        void        (*exited)       (GsmApp *app,
-                                     int     status);
+        void        (*exited)       (GsmApp *app);
+        void        (*died)         (GsmApp *app);
         void        (*registered)   (GsmApp *app);
 
         /* virtual methods */
@@ -84,6 +84,7 @@
 gboolean         gsm_app_is_running      (GsmApp     *app);
 
 void             gsm_app_exited          (GsmApp     *app);
+void             gsm_app_died            (GsmApp     *app);
 
 
 const char      *gsm_app_get_basename    (GsmApp     *app);

Modified: branches/dbus_based/gnome-session/gsm-autostart-app.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-autostart-app.c	(original)
+++ branches/dbus_based/gnome-session/gsm-autostart-app.c	Fri Jun 13 21:21:12 2008
@@ -35,6 +35,7 @@
         gboolean              condition;
         EggDesktopFile       *desktop_file;
         GPid                  pid;
+        guint                 child_watch_id;
         char                 *startup_id;
 };
 
@@ -429,12 +430,29 @@
 }
 
 static void
-app_exited (GPid    pid,
-            int     status,
-            GsmApp *app)
-{
+app_exited (GPid             pid,
+            int              status,
+            GsmAutostartApp *app)
+{
+        g_debug ("GsmAutostartApp: (pid:%d) done (%s:%d)",
+                 (int) pid,
+                 WIFEXITED (status) ? "status"
+                 : WIFSIGNALED (status) ? "signal"
+                 : "unknown",
+                 WIFEXITED (status) ? WEXITSTATUS (status)
+                 : WIFSIGNALED (status) ? WTERMSIG (status)
+                 : -1);
+
+        g_spawn_close_pid (app->priv->pid);
+        app->priv->pid = -1;
+        app->priv->child_watch_id = 0;
+
         if (WIFEXITED (status)) {
-                gsm_app_exited (app);
+                int code = WEXITSTATUS (status);
+                gsm_app_exited (GSM_APP (app));
+        } else if (WIFSIGNALED (status)) {
+                int num = WTERMSIG (status);
+                gsm_app_died (GSM_APP (app));
         }
 }
 
@@ -470,13 +488,10 @@
         g_free (env[0]);
 
         if (success) {
-                /* In case the app belongs to Initialization phase, we monitor
-                 * if it exits to emit proper "exited" signal to session. */
-                if (gsm_app_get_phase (app) == GSM_MANAGER_PHASE_INITIALIZATION) {
-                        g_child_watch_add ((GPid) aapp->priv->pid,
-                                           (GChildWatchFunc)app_exited,
-                                           app);
-                }
+                g_debug ("GsmAutostartApp: started pid:%d", aapp->priv->pid);
+                aapp->priv->child_watch_id = g_child_watch_add ((GPid) aapp->priv->pid,
+                                                                (GChildWatchFunc)app_exited,
+                                                                app);
 
                 return TRUE;
         } else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]