summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 20d32d57c3..603e0f9a08 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -93,7 +93,7 @@ static struct ChildRecord *CreateChild(const char *, const char *, SECURITY_ATTR
static bool has_redirection(const char *);
static void StartSockets ();
static DWORD wait_events(HANDLE event, DWORD timeout);
-#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
+#if !defined(_WIN32_WCE)
static int rb_w32_open_osfhandle(long osfhandle, int flags);
#else
#define rb_w32_open_osfhandle(osfhandle, flags) _open_osfhandle(osfhandle, flags)
@@ -1637,6 +1637,19 @@ rb_w32_open_osfhandle(long osfhandle, int flags)
#endif
+#ifdef __BORLANDC__
+static int
+rb_w32_open_osfhandle(long osfhandle, int flags)
+{
+ int fd = _open_osfhandle(osfhandle, flags);
+ if (fd == -1) {
+ errno = EMFILE; /* too many open files */
+ _doserrno = 0L; /* not an OS error */
+ }
+ return fd;
+}
+#endif
+
#undef getsockopt
static int
@@ -3231,6 +3244,7 @@ rb_w32_close(int fd)
return _close(fd);
}
_set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE);
+ _close(fd);
if (closesocket(sock) == SOCKET_ERROR) {
errno = map_errno(WSAGetLastError());
return -1;