diff options
Diffstat (limited to 'otherlibs/unix/readlink.c')
-rw-r--r-- | otherlibs/unix/readlink.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/otherlibs/unix/readlink.c b/otherlibs/unix/readlink.c index 9534a42bd..d129aebfe 100644 --- a/otherlibs/unix/readlink.c +++ b/otherlibs/unix/readlink.c @@ -12,8 +12,10 @@ /***********************************************************************/ #include <mlvalues.h> +#include <memory.h> #include <alloc.h> #include <fail.h> +#include <signals.h> #ifdef HAS_SYMLINK @@ -30,12 +32,18 @@ CAMLprim value unix_readlink(value path) { + CAMLparam1(path); char buffer[PATH_MAX]; int len; - len = readlink(String_val(path), buffer, sizeof(buffer) - 1); + char * p; + p = caml_stat_alloc_string(path); + caml_enter_blocking_section(); + len = readlink(p, buffer, sizeof(buffer) - 1); + caml_leave_blocking_section(); + caml_stat_free(p); if (len == -1) uerror("readlink", path); buffer[len] = '\0'; - return copy_string(buffer); + CAMLreturn(copy_string(buffer)); } #else |