aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-21 22:45:10 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-21 22:45:10 +0900
commit5798d35ff66e468ebf296c4069ede275d7fb0ec9 (patch)
tree1cf03b39f584f9a0cbd20fc9c48729cc597f3b89 /io.c
parent25f2005a638570cce832d218a451072057610f06 (diff)
downloadruby-5798d35ff66e468ebf296c4069ede275d7fb0ec9.tar.gz
Also check EWOULDBLOCK as well as EAGAIN
Diffstat (limited to 'io.c')
-rwxr-xr-xio.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/io.c b/io.c
index 51d92a942f..201ec9bede 100755
--- a/io.c
+++ b/io.c
@@ -316,7 +316,6 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
static const int retry_max_count = 10000;
int retry_count = 0;
- int e;
#ifdef O_CLOEXEC
/* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
@@ -325,15 +324,11 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
flags |= O_NOINHERIT;
#endif
- while (1) {
- ret = open(pathname, flags, mode);
- e = errno;
-
- if (ret != -1 || e != EAGAIN || retry_count >= retry_max_count) {
- break;
- }
+ while ((ret = open(pathname, flags, mode)) == -1) {
+ int e = errno;
+ if (e != EAGAIN && e != EWOULDBLOCK) break;
+ if (retry_count++ >= retry_max_count) break;
- retry_count++;
sleep(retry_interval);
}