Index: tclWinChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinChan.c,v
retrieving revision 1.16
diff -c -r1.16 tclWinChan.c
*** tclWinChan.c	2001/10/15 17:34:53	1.16
--- tclWinChan.c	2001/11/21 03:03:17
***************
*** 934,945 ****
  	channel = TclWinOpenConsoleChannel(handle, channelName, mode);
  	break;
      case FILE_TYPE_PIPE:
! 	if (mode & TCL_READABLE)
! 	{
  	    readFile = TclWinMakeFile(handle);
! 	}
! 	if (mode & TCL_WRITABLE)
! 	{
  	    writeFile = TclWinMakeFile(handle);
  	}
  	channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
--- 934,954 ----
  	channel = TclWinOpenConsoleChannel(handle, channelName, mode);
  	break;
      case FILE_TYPE_PIPE:
! 	if ((mode & TCL_READABLE) && (mode & TCL_WRITABLE)) {
! 	    HANDLE dupe;
! 
! 	    /*
! 	     *  We need to make a duplicate, because the handles are closed
! 	     *  seperately by the core in the close2proc.
! 	     */
! 	    DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),
! 		    &dupe, 0, FALSE, DUPLICATE_SAME_ACCESS);
! 
!     	    readFile = TclWinMakeFile(handle);
! 	    writeFile = TclWinMakeFile(dupe);
! 	} else if (mode & TCL_READABLE)	{
  	    readFile = TclWinMakeFile(handle);
! 	} else if (mode & TCL_WRITABLE)	{
  	    writeFile = TclWinMakeFile(handle);
  	}
  	channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
