summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/dir.c b/dir.c
index 378396a9f7..be20c43ce1 100644
--- a/dir.c
+++ b/dir.c
@@ -1002,11 +1002,7 @@ nogvl_chdir(void *ptr)
static void
dir_chdir(VALUE path)
{
- int r;
- char *p = RSTRING_PTR(path);
-
- r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p, RUBY_UBF_IO, 0);
- if (r < 0)
+ if (chdir(RSTRING_PTR(path)) < 0)
rb_sys_fail_path(path);
}
@@ -1111,7 +1107,13 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
args.done = FALSE;
return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
}
- dir_chdir(path);
+ else {
+ char *p = RSTRING_PTR(path);
+ int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p,
+ RUBY_UBF_IO, 0);
+ if (r < 0)
+ rb_sys_fail_path(path);
+ }
return INT2FIX(0);
}