diff -Naur gdm-2.31.1.orig/daemon/gdm-simple-slave.c gdm-2.31.1/daemon/gdm-simple-slave.c
--- gdm-2.31.1.orig/daemon/gdm-simple-slave.c	2010-05-25 00:58:38.000000000 +0300
+++ gdm-2.31.1/daemon/gdm-simple-slave.c	2010-07-07 09:19:30.413234438 +0300
@@ -84,6 +84,7 @@
 
         guint              start_session_when_ready : 1;
         guint              waiting_to_start_session : 1;
+        guint              need_to_run_postsession  : 1;
 };
 
 enum {
@@ -118,6 +119,9 @@
          * be checked by calling:
          * gdm_session_direct_bypasses_xsession (session)
          */
+
+        /* PostSession script needs to be run. */
+        slave->priv->need_to_run_postsession = 1;
 }
 
 static void
@@ -129,10 +133,12 @@
 
         g_debug ("GdmSimpleSlave: session exited with code %d\n", exit_code);
 
-        /* Run the PostSession script. gdmslave suspends until script has terminated */
+        /* Always run the PostSession script. gdmslave suspends until script has terminated */
+        slave->priv->need_to_run_postsession = 0;
         username = gdm_session_direct_get_username (slave->priv->session);
         gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
 
+
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
 
@@ -141,10 +147,20 @@
                  int             signal_number,
                  GdmSimpleSlave *slave)
 {
+        char *username;
+
         g_debug ("GdmSimpleSlave: session died with signal %d, (%s)",
                  signal_number,
                  g_strsignal (signal_number));
 
+        if (slave->priv->need_to_run_postsession) {
+                slave->priv->need_to_run_postsession = 0;
+
+                /* Run the PostSession script. gdmslave suspends until script has terminated */
+                username = gdm_session_direct_get_username (slave->priv->session);
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        }
+
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
 
@@ -630,6 +646,8 @@
                                                        display_device,
                                                        display_x11_authority_file,
                                                        display_is_local);
+        slave->priv->need_to_run_postsession = 0;
+
         g_free (display_id);
         g_free (display_name);
         g_free (display_device);
