Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.540
diff -u -r1.540 ChangeLog
--- ChangeLog	2001/08/24 16:46:46	1.540
+++ ChangeLog	2001/08/24 23:17:13
@@ -1,3 +1,13 @@
+2001-08-24  Andreas Kupries <andreas_kupries@users.sourceforge.net>
+
+	* generic/tclIO.c (Tcl_GetStdChannel): Moved setting the
+	  '*Initialized'-flags into the conditionals below them. IOW, the
+	  flags are set only if the standard channels could actually be
+	  initialized to their defaults. If that was impossible, for
+	  example when running as a Windows NT service, the standard
+	  channels stay uninitialized and the next three channels are
+	  *not* made into standard channels [419685].
+
 2001-08-24 Vince Darley <vincentdarley@users.sourceforge.net>
 
 	* doc/glob.n: documented windows-style path issue with glob.
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.34
diff -u -r1.34 tclIO.c
--- generic/tclIO.c	2001/08/23 17:37:07	1.34
+++ generic/tclIO.c	2001/08/24 23:17:13
@@ -347,7 +347,6 @@
 	case TCL_STDIN:
 	    if (!tsdPtr->stdinInitialized) {
 		tsdPtr->stdinChannel = TclpGetDefaultStdChannel(TCL_STDIN);
-		tsdPtr->stdinInitialized = 1;
 
 		/*
                  * Artificially bump the refcount to ensure that the channel
@@ -359,6 +358,14 @@
                  */
 
                 if (tsdPtr->stdinChannel != (Tcl_Channel) NULL) {
+		    /*
+		     * Note that we are not allowed to move this
+		     * assignment behind Tcl_RegisterChannel or we
+		     * will create an infinite recursion through
+		     * Tcl_RegisterChannel - GetChannelTable -
+		     * and Tcl_GetStdChannel.
+		     */
+		    tsdPtr->stdinInitialized = 1;
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stdinChannel);
                 }
@@ -368,8 +375,8 @@
 	case TCL_STDOUT:
 	    if (!tsdPtr->stdoutInitialized) {
 		tsdPtr->stdoutChannel = TclpGetDefaultStdChannel(TCL_STDOUT);
-		tsdPtr->stdoutInitialized = 1;
                 if (tsdPtr->stdoutChannel != (Tcl_Channel) NULL) {
+		    tsdPtr->stdoutInitialized = 1;
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stdoutChannel);
                 }
@@ -379,8 +386,8 @@
 	case TCL_STDERR:
 	    if (!tsdPtr->stderrInitialized) {
 		tsdPtr->stderrChannel = TclpGetDefaultStdChannel(TCL_STDERR);
-		tsdPtr->stderrInitialized = 1;
                 if (tsdPtr->stderrChannel != (Tcl_Channel) NULL) {
+		    tsdPtr->stderrInitialized = 1;
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stderrChannel);
                 }
