--- gdm-2.30.2.is.2.30.0/daemon/gdm-simple-slave.c
+++ gdm-2.30.2.is.2.30.0.new/daemon/gdm-simple-slave.c
@@ -84,6 +84,7 @@
 
         guint              start_session_when_ready : 1;
         guint              waiting_to_start_session : 1;
+        guint              need_to_run_postsession  : 1;
         guint              plymouth_is_running : 1;
   
         gchar             *username;
@@ -122,6 +123,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
@@ -133,9 +137,13 @@
 
         g_debug ("GdmSimpleSlave: session exited with code %d\n", exit_code);
 
-        /* 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);
+        /* Run the PostSession script, if necessary, suspending gdmslave while running. */
+        if (slave->priv->need_to_run_postsession) {
+                char *username;
+                username = gdm_session_direct_get_username (slave->priv->session);
+                slave->priv->need_to_run_postsession = 0;
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        }
 
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
@@ -145,10 +153,19 @@
                  int             signal_number,
                  GdmSimpleSlave *slave)
 {
+
         g_debug ("GdmSimpleSlave: session died with signal %d, (%s)",
                  signal_number,
                  g_strsignal (signal_number));
 
+        /* Run the PostSession script, if necessary, suspending gdmslave while running. */
+        if (slave->priv->need_to_run_postsession) {
+                char *username;
+                username = gdm_session_direct_get_username (slave->priv->session);
+                slave->priv->need_to_run_postsession = 0;
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        }
+
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
 
@@ -650,7 +667,7 @@
         if (slave->priv->server != NULL) {
                 display_device = gdm_server_get_display_device (slave->priv->server);
         }
-
+        slave->priv->need_to_run_postsession = 0;
         slave->priv->session = gdm_session_direct_new (display_id,
                                                        display_name,
                                                        display_hostname,
