From d6379666cad4bda4e147b9f9bb2d07a80a1a3aa9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 17 Oct 2015 23:41:14 +0000 Subject: [PATCH] file.c: set errno * file.c (ruby_is_fd_loadable): set proper errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 3 ++- ruby.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index 6f3a4378fd..b2ad989df6 100644 --- a/file.c +++ b/file.c @@ -5683,9 +5683,10 @@ ruby_is_fd_loadable(int fd) if (S_ISREG(st.st_mode)) return 1; - if (S_ISFIFO(st.st_mode)) + if (!S_ISDIR(st.st_mode)) return 1; + errno = EISDIR; return 0; #endif } diff --git a/ruby.c b/ruby.c index bde78f17f3..2f3e9409ca 100644 --- a/ruby.c +++ b/ruby.c @@ -1803,8 +1803,9 @@ open_load_file(VALUE fname_v, int *xflag) } #endif if (!ruby_is_fd_loadable(fd)) { + int e = errno; (void)close(fd); - rb_load_fail(fname_v, strerror(errno)); + rb_load_fail(fname_v, strerror(e)); } f = rb_io_fdopen(fd, mode, fname);