Index: gnome-session/headers.h
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/headers.h,v
retrieving revision 1.12
diff -u -r1.12 headers.h
--- gnome-session/headers.h	9 Jun 2003 19:04:52 -0000	1.12
+++ gnome-session/headers.h	5 Aug 2003 21:12:19 -0000
@@ -106,6 +106,9 @@
   /* Handle for the GsmCommand protocol */
   gchar* handle;
 
+  /* Process id of a started client */
+  gint pid;
+
   /* Client's connection.  */
   SmsConn connection;
 
@@ -160,6 +163,11 @@
 /* Milliseconds to wait for clients to register before assuming that
  * they have finished any initialisation needed by other clients. */
 extern guint purge_delay;
+
+/* Milliseconds to wait between checking if the client is still alive. 
+ * This is to be able to detect clients that exists without registering 
+ * during session startup. */
+extern guint check_running_delay;
 
 /* Milliseconds to wait for clients to die before cutting our throat. */
 extern guint suicide_delay;
Index: gnome-session/main.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/main.c,v
retrieving revision 1.58
diff -u -r1.58 main.c
--- gnome-session/main.c	28 Jul 2003 15:48:35 -0000	1.58
+++ gnome-session/main.c	5 Aug 2003 21:12:19 -0000
@@ -71,6 +71,9 @@
 /* Wait period for clients to register. */
 guint purge_delay = 120000;
 
+/* Wait period between checking that started clients are still alive. */
+guint check_running_delay = 1000;
+
 /* Wait period for clients to save. */
 guint warn_delay = 120000;
 
Index: gnome-session/manager.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/manager.c,v
retrieving revision 1.78
diff -u -r1.78 manager.c
--- gnome-session/manager.c	25 Feb 2003 08:50:09 -0000	1.78
+++ gnome-session/manager.c	5 Aug 2003 21:12:20 -0000
@@ -23,6 +23,7 @@
 #include <gtk/gtk.h>
 #include <libgnome/libgnome.h>
 #include <unistd.h>
+#include <signal.h>
 #include <errno.h>
 #ifndef errno
 extern int errno;
@@ -521,6 +522,36 @@
   return 0;
 }
 
+/* If client is in pending_list and is found not to be running at all,
+ * remove it from pending_list and call update_save_state().
+ * Otherwise reset the timer. Method is used to purge client that exists
+ * without registering with the session manager.
+ */
+static gint
+check_running (gpointer data)
+{
+       Client* client = (Client*)data;
+
+       if (! g_slist_find (pending_list, client)) {
+               /* This is already gone from list. */
+               return 0;
+       }
+       if ((kill (client->pid, 0) < 0) && (errno == ESRCH)) {
+               /* This client does not exist, remove it. */
+               REMOVE (pending_list, client);
+	       free_client (client);
+               update_save_state();
+               return 0;
+       }
+       if (check_running_delay) {
+               /* Give the client some more time. */
+               gtk_timeout_add (check_running_delay,
+                                check_running,
+                                (gpointer)client);
+       }
+       return 0;
+}
+
 static void
 reincarnate_client (Client *old_client,
 		    Client *new_client)
@@ -553,13 +584,11 @@
 void
 start_client (Client* client)
 {
-  int pid;
-
   client_event (client->handle, GsmStart);
 
-  pid = run_command (client, SmRestartCommand);
+  client->pid = run_command (client, SmRestartCommand);
 
-  if (pid == -1)
+  if (client->pid == -1)
     {
       client_event (client->handle, GsmRemove);
       free_client(client);
@@ -571,6 +600,10 @@
       APPEND (pending_list, client);
       if (purge_delay)
 	gtk_timeout_add (purge_delay, purge, (gpointer)client); 
+      if (check_running_delay)
+        gtk_timeout_add (check_running_delay,
+                         check_running,
+                         (gpointer)client);
     }
   else
     {
