summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/dup2.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/dup2.c')
-rw-r--r--otherlibs/win32unix/dup2.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/otherlibs/win32unix/dup2.c b/otherlibs/win32unix/dup2.c
index 08e474b56..c9612620c 100644
--- a/otherlibs/win32unix/dup2.c
+++ b/otherlibs/win32unix/dup2.c
@@ -28,6 +28,10 @@ CAMLprim value unix_dup2(value fd1, value fd2)
return -1;
}
Handle_val(fd2) = newh;
- CloseHandle(oldh);
+ if (Descr_kind_val(fd2) == KIND_SOCKET)
+ closesocket((SOCKET) oldh);
+ else
+ CloseHandle(oldh);
+ Descr_kind_val(fd2) = Descr_kind_val(fd1);
return Val_unit;
}