aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/io.c b/io.c
index 22257b65ae..83c51f4437 100644
--- a/io.c
+++ b/io.c
@@ -1247,9 +1247,11 @@ void rb_io_set_nonblock(OpenFile *fptr)
#else
flags = 0;
#endif
- flags |= O_NONBLOCK;
- if (fcntl(fptr->fd, F_SETFL, flags) == -1) {
- rb_sys_fail(fptr->path);
+ if ((flags & O_NONBLOCK) == 0) {
+ flags |= O_NONBLOCK;
+ if (fcntl(fptr->fd, F_SETFL, flags) == -1) {
+ rb_sys_fail(fptr->path);
+ }
}
}