+ new_fd <- case other_side of
+ Nothing -> throwErrnoIfMinus1 "dupHandle" $ c_dup (haFD h_)
+ Just r -> withHandle_' "dupHandle" h r (return . haFD)
+ dupHandle_ other_side h_ new_fd
+
+dupHandleTo other_side hto_ h_ = do
+ flushBuffer h_
+ -- Windows' dup2 does not return the new descriptor, unlike Unix
+ throwErrnoIfMinus1 "dupHandleTo" $
+ c_dup2 (haFD h_) (haFD hto_)
+ dupHandle_ other_side h_ (haFD hto_)
+
+dupHandle_ :: Maybe (MVar Handle__) -> Handle__ -> FD
+ -> IO (Handle__, Handle__)
+dupHandle_ other_side h_ new_fd = do