diff -Naur gdm-2.31.90.original/daemon/gdm-simple-slave.c gdm-2.31.90/daemon/gdm-simple-slave.c
--- gdm-2.31.90.original/daemon/gdm-simple-slave.c
+++ gdm-2.31.90/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;
 };
 
 enum {
@@ -108,9 +109,11 @@
 
         g_debug ("GdmSimpleSlave: session started %d", pid);
 
+
         /* Run the PreSession script. gdmslave suspends until script has terminated */
         username = gdm_session_direct_get_username (slave->priv->session);
         if (username != NULL) {
+                slave->priv->need_to_run_postsession = 1;
                 gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PreSession", username);
         }
         g_free (username);
@@ -132,12 +135,15 @@
 
         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);
-        if (username != NULL) {
-                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+        /* Run the PostSession script if necessary. */
+        if (slave->priv->need_to_run_postsession) {
+                username = gdm_session_direct_get_username (slave->priv->session);
+                if (username != NULL) {
+                        gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+                        slave->priv->need_to_run_postsession = 0;
+                }
+                g_free (username);
         }
-        g_free (username);
 
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
@@ -147,10 +153,22 @@
                  int             signal_number,
                  GdmSimpleSlave *slave)
 {
+        char *username;
+
         g_debug ("GdmSimpleSlave: session died with signal %d, (%s)",
                  signal_number,
                  g_strsignal (signal_number));
 
+        /* Run the PostSession script if necessary. */
+        if (slave->priv->need_to_run_postsession) {
+                username = gdm_session_direct_get_username (slave->priv->session);
+                if (username != NULL) {
+                        gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostSession", username);
+                        slave->priv->need_to_run_postsession = 0;
+                }
+                g_free (username);
+        }
+
         gdm_slave_stopped (GDM_SLAVE (slave));
 }
 
@@ -661,6 +679,8 @@
                 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,
