summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/io.c b/io.c
index 228149df8f..8fc0957582 100644
--- a/io.c
+++ b/io.c
@@ -1196,9 +1196,11 @@ void rb_io_set_nonblock(OpenFile *fptr)
#else
flags = 0;
#endif
- flags |= O_NONBLOCK;
- if (fcntl(fileno(fptr->f), F_SETFL, flags) == -1) {
- rb_sys_fail(fptr->path);
+ if ((flags & O_NONBLOCK) == 0) {
+ flags |= O_NONBLOCK;
+ if (fcntl(fileno(fptr->f), F_SETFL, flags) == -1) {
+ rb_sys_fail(fptr->path);
+ }
}
if (fptr->f2) {
#ifdef F_GETFL
@@ -1209,9 +1211,11 @@ void rb_io_set_nonblock(OpenFile *fptr)
#else
flags = 0;
#endif
- flags |= O_NONBLOCK;
- if (fcntl(fileno(fptr->f2), F_SETFL, flags) == -1) {
- rb_sys_fail(fptr->path);
+ if ((flags & O_NONBLOCK) == 0) {
+ flags |= O_NONBLOCK;
+ if (fcntl(fileno(fptr->f2), F_SETFL, flags) == -1) {
+ rb_sys_fail(fptr->path);
+ }
}
}
}