--- gnome-session/gsm-sound.c.orig	2006-05-18 07:38:56.000000000 +0200
+++ gnome-session/gsm-sound.c	2006-05-18 07:41:24.000000000 +0200
@@ -11,6 +11,8 @@
 #define ENABLE_ESD_KEY    "/desktop/gnome/sound/enable_esd"
 #define ENABLE_SOUNDS_KEY "/desktop/gnome/sound/event_sounds"
 
+static GPid esd_pid = 0;
+
 static gboolean
 esd_enabled (void)
 {
@@ -56,11 +58,13 @@
 {
   GError *err = NULL;
   time_t starttime;
+  gchar *argv[] = {ESD_SERVER, "-nobeeps", NULL};
 
-  if (!g_spawn_command_line_async (ESD_SERVER" -nobeeps", &err))
+  if (!g_spawn_async ("/", argv, NULL, 0, NULL, NULL, &esd_pid, &err))
     {
       g_warning ("Could not start esd: %s\n", err->message);
       g_error_free (err);
+      esd_pid = 0;
       return;
     }
 
@@ -77,6 +81,19 @@
     }
 }
 
+static void
+stop_esd_delayed (void)
+{
+  if (esd_pid)
+    {
+      gchar *command = g_strdup_printf ("sleep 5 ; kill %i", esd_pid);
+      gchar *argv[] = {"/bin/sh", "-c", command, NULL};
+      g_spawn_async ("/", argv, NULL, 0, NULL, NULL, NULL, NULL);
+      esd_pid = 0;
+      g_free (command);
+    }
+}
+
 static gboolean
 load_login_sample_from (const char *file)
 {
@@ -189,5 +206,6 @@
 #ifdef HAVE_ESD
   if (sound_events_enabled ())
     play_trigger ("logout");
+  stop_esd_delayed ();
 #endif
 }
