fix hDuplicateTo on Windows
authorSimon Marlow <simonmar@microsoft.com>
Fri, 1 Sep 2006 15:00:16 +0000 (15:00 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Fri, 1 Sep 2006 15:00:16 +0000 (15:00 +0000)
deja vu - I'm sure I remember fixing this before...

GHC/Handle.hs

index be7f147..18bf135 100644 (file)
@@ -1565,9 +1565,10 @@ dupHandle other_side h_ = do
 
 dupHandleTo other_side hto_ h_ = do
   flushBuffer h_
-  new_fd <- throwErrnoIfMinus1 "dupHandleTo" $ 
-               c_dup2 (fromIntegral (haFD h_)) (fromIntegral (haFD hto_))
-  dupHandle_ other_side h_ new_fd
+  -- Windows' dup2 does not return the new descriptor, unlike Unix
+  throwErrnoIfMinus1 "dupHandleTo" $ 
+       c_dup2 (fromIntegral (haFD h_)) (fromIntegral (haFD hto_))
+  dupHandle_ other_side h_ (haFD hto_)
 
 dupHandle_ other_side h_ new_fd = do
   buffer <- allocateBuffer dEFAULT_BUFFER_SIZE (initBufferState (haType h_))