--- kdebase-3.5.8/kdm/backend/dm.c	2008-02-13 23:59:17.000000000 +0200
+++ kdebase-3.5.8/kdm/backend/dm.c	2008-02-14 11:22:41.000000000 +0200
@@ -996,9 +996,14 @@ ReapChildren( void )
 				/* don't kill again */
 				break;
 			case running:
-				if (startingServer == d && d->serverStatus != ignore) {
-					if (d->serverStatus == starting && waitCode( status ) != 47)
-						LogError( "X server died during startup\n" );
+				LogError("X server terminated: [%d, %d, %d]\n",
+					(startingServer == d),
+					(d->serverStatus),
+					(waitCode(status)));
+
+				if (startingServer == d /*&& d->serverStatus != ignore*/) {
+					if (/*d->serverStatus == starting &&*/ waitCode( status ) != 47)
+					LogError( "X server died during startup\n" );
 					StartServerFailed();
 					break;
 				}
--- kdebase-3.5.8/kdm/backend/server.c	2008-02-13 23:59:17.000000000 +0200
+++ kdebase-3.5.8/kdm/backend/server.c	2008-02-14 11:41:20.000000000 +0200
@@ -48,6 +48,10 @@ from the copyright holder.
 struct display *startingServer;
 time_t serverTimeout = TO_INF;
 
+#define SERVER_ATTEMPTS 3
+
+char* failsafeXServer[] = {"/etc/gdm/failsafeXServer", 0};
+
 char **
 PrepServerArgv( struct display *d, const char *args )
 {
@@ -128,6 +132,7 @@ StartServer( struct display *d )
 {
 	startingServer = d;
 	d->startTries = 0;
+	d->serverAttempts = SERVER_ATTEMPTS;
 	StartServerOnce();
 }
 
@@ -150,6 +155,7 @@ void
 StartServerSuccess()
 {
 	struct display *d = startingServer;
+	LogError("StartServerSucces\n");
 	d->serverStatus = ignore;
 	serverTimeout = TO_INF;
 	Debug( "X server ready, starting session\n" );
@@ -161,9 +167,14 @@ StartServerFailed()
 {
 	struct display *d = startingServer;
 	if (!d->serverAttempts || d->startTries < d->serverAttempts) {
+		LogError("Failed to start X server. Starting failsafe X server.\n");
+
+		runAndWait(failsafeXServer, 0);
+
 		d->serverStatus = pausing;
 		serverTimeout = d->openDelay + now;
 	} else {
+		LogError("StartServerFailed\n");
 		d->serverStatus = ignore;
 		serverTimeout = TO_INF;
 		startingServer = 0;
