summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/chdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/chdir.c')
-rw-r--r--otherlibs/unix/chdir.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/otherlibs/unix/chdir.c b/otherlibs/unix/chdir.c
index e7ea6f505..4b93b5fc8 100644
--- a/otherlibs/unix/chdir.c
+++ b/otherlibs/unix/chdir.c
@@ -12,12 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_chdir(value path)
{
+ CAMLparam1(path);
+ char * p;
int ret;
- ret = chdir(String_val(path));
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = chdir(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("chdir", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}