Index: /trunk/source/lisp-kernel/lisp-debug.c
===================================================================
--- /trunk/source/lisp-kernel/lisp-debug.c	(revision 12827)
+++ /trunk/source/lisp-kernel/lisp-debug.c	(revision 12828)
@@ -53,4 +53,9 @@
   if (f) {
     if (setvbuf(f, NULL, _IONBF, 0) == 0) {
+#ifdef WINDOWS
+      if (fileno(stdin) < 0) {
+        fileno(stdin) = 0;
+      }
+#endif
       dbgout = f;
       return true;
@@ -115,44 +120,4 @@
 
 
-#ifdef WINDOWS
-Boolean first_debugger_call = TRUE;
-
-void
-setup_debugger_streams()
-{
-  HANDLE h;
-  int fd;
-  FILE *f;
-
-  if (first_debugger_call) {
-    first_debugger_call = FALSE;
-    if (stdin_is_dev_null())
-      AllocConsole();
-    // Reassociate C's stdin with Windows' stdin
-    h = GetStdHandle(STD_INPUT_HANDLE);
-    fd = _open_osfhandle((intptr_t)h, _O_TEXT);
-    if (fd >= 0) {
-      f = _fdopen(fd, "r");
-      *stdin = *f;
-    }
-    // Reassociate C's stdout with Windows' stdout
-    h = GetStdHandle(STD_OUTPUT_HANDLE);
-    fd = _open_osfhandle((intptr_t)h, _O_TEXT);
-    if (fd >= 0) {
-      f = _fdopen(fd, "w");
-      *stdout = *f;
-    }
-    // Reassociate C's stderr with Windows' stderr
-    h = GetStdHandle(STD_ERROR_HANDLE);
-    fd = _open_osfhandle((intptr_t)h, _O_TEXT);
-    if (fd >= 0) {
-      f = _fdopen(fd, "w");
-      *stderr = *f;
-    }
-    dbgout = stderr;
-  }
-  return;
-}
-#endif
 
 
@@ -750,7 +715,4 @@
 {
 
-#ifdef WINDOWS
-  setup_debugger_streams();
-#endif
 
 #ifdef PPC
@@ -1180,7 +1142,4 @@
   debug_command_return state = debug_continue;
 
-#ifdef WINDOWS
-  setup_debugger_streams();
-#endif
 
   if (stdin_is_dev_null()) {
@@ -1237,5 +1196,5 @@
     fprintf(dbgout, "[%d] Clozure CL kernel debugger: ", main_thread_pid);
 #endif
-    fflush(dbgout);
+    fflush(dbgout);             /* dbgout should be unbuffered, so this shouldn't be necessary.  But it can't hurt ... */
     state = apply_debug_command(xp, readc(), info, why);
   }
