summaryrefslogtreecommitdiff
path: root/otherlibs/unix/readlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/readlink.c')
-rw-r--r--otherlibs/unix/readlink.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/otherlibs/unix/readlink.c b/otherlibs/unix/readlink.c
index 9534a42bde..d129aebfed 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