Permalink
Browse files

rb_sys_fail uses current errno value

Signed-off-by: Tim Felgentreff <timfelgentreff@gmail.com>
  • Loading branch information...
1 parent 587f140 commit 863c67e79f3b354e189635f9568404a9da554718 @tmm1 committed with timfel Apr 3, 2011
Showing with 6 additions and 2 deletions.
  1. +1 −1 cext/src/jruby-cext.cpp
  2. +2 −1 cext/src/ruby.cpp
  3. +3 −0 src/org/jruby/cext/JRuby.java
View
@@ -349,7 +349,7 @@ loadIds(JNIEnv* env)
"(Lorg/jruby/Ruby;Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)J");
Ruby_defineReadonlyVariable_method = getMethodID(env, Ruby_class, "defineReadonlyVariable",
"(Ljava/lang/String;Lorg/jruby/runtime/builtin/IRubyObject;)V");
- JRuby_sysFail = getStaticMethodID(env, JRuby_class, "sysFail", "(Lorg/jruby/Ruby;Ljava/lang/String;)V");
+ JRuby_sysFail = getStaticMethodID(env, JRuby_class, "sysFail", "(Lorg/jruby/Ruby;Ljava/lang/String;I)V");
RubyString_resize_method = getMethodID(env, RubyString_class, "resize", "(I)V");
RubyArray_newArray = getStaticMethodID(env, RubyArray_class, "newArray", "(Lorg/jruby/Ruby;J)Lorg/jruby/RubyArray;");
RubyArray_clear_method = getMethodID(env, RubyArray_class, "clear", "()V");
View
@@ -26,6 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
+#include <errno.h>
#include "Handle.h"
#include "jruby.h"
#include "ruby.h"
@@ -206,7 +207,7 @@ extern "C" void
rb_sys_fail(const char* msg)
{
JLocalEnv env;
- env->CallVoidMethod(JRuby_class, JRuby_sysFail, getRuntime(), env->NewStringUTF(msg));
+ env->CallVoidMethod(JRuby_class, JRuby_sysFail, getRuntime(), env->NewStringUTF(msg), errno);
}
extern "C" void
@@ -247,7 +247,10 @@ public static void clearErrorInfo(Ruby runtime) {
/** rb_sys_fail */
public static void sysFail(Ruby runtime, String message) {
final int n = LastError.getLastError();
+ sysFail(runtime, message, n);
+ }
+ public static void sysFail(Ruby runtime, String message, int n) {
IRubyObject arg = (message != null) ? runtime.newString(message) : runtime.getNil();
RubyClass instance = runtime.getErrno(n);

0 comments on commit 863c67e

Please sign in to comment.