aboutsummaryrefslogtreecommitdiffstats
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 820b16c40b..d28bd56452 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4429,11 +4429,11 @@ fcntl(int fd, int cmd, ...)
/* License: Ruby's */
int
-rb_w32_set_nonblock(int fd)
+rb_w32_set_nonblock2(int fd, int nonblock)
{
SOCKET sock = TO_SOCKET(fd);
if (is_socket(sock)) {
- return setfl(sock, O_NONBLOCK);
+ return setfl(sock, nonblock ? O_NONBLOCK : 0);
}
else if (is_pipe(sock)) {
DWORD state;
@@ -4441,7 +4441,12 @@ rb_w32_set_nonblock(int fd)
errno = map_errno(GetLastError());
return -1;
}
- state |= PIPE_NOWAIT;
+ if (nonblock) {
+ state |= PIPE_NOWAIT;
+ }
+ else {
+ state &= ~PIPE_NOWAIT;
+ }
if (!SetNamedPipeHandleState((HANDLE)sock, &state, NULL, NULL)) {
errno = map_errno(GetLastError());
return -1;
@@ -4454,6 +4459,12 @@ rb_w32_set_nonblock(int fd)
}
}
+int
+rb_w32_set_nonblock(int fd)
+{
+ return rb_w32_set_nonblock2(fd, TRUE);
+}
+
#ifndef WNOHANG
#define WNOHANG -1
#endif