summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-14 07:03:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-14 07:03:01 +0000
commita4e6f7d707293a71727ad18e75aae9639ba423f3 (patch)
tree490c0990e164882da43fdb2c52461723d7ca47c6 /file.c
parentfcadcd3e68982ee727c0cc59bedadfc16b9ca214 (diff)
ruby.c: reduce fstat
* file.c (ruby_is_fd_loadable): now return -1 if loadable but may block. * ruby.c (open_load_file): wait to read by the result of ruby_is_fd_loadable, without fstat. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/file.c b/file.c
index 9f430a3382..96dd1b247e 100644
--- a/file.c
+++ b/file.c
@@ -5644,11 +5644,12 @@ ruby_is_fd_loadable(int fd)
if (fstat(fd, &st) < 0)
return 0;
+
if (S_ISREG(st.st_mode))
return 1;
if (S_ISFIFO(st.st_mode))
- return 1;
+ return -1;
if (S_ISDIR(st.st_mode))
errno = EISDIR;