summaryrefslogtreecommitdiff
path: root/otherlibs/unix/readlink.c
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2014-03-31 17:58:53 +0000
committerDamien Doligez <damien.doligez-inria.fr>2014-03-31 17:58:53 +0000
commit8643356b8542e0dcab358716f1e04d47b08b1a6d (patch)
treee10cc5a03f7ead69a2d4ed563cbd021df5770ef2 /otherlibs/unix/readlink.c
parentcd1bf4b9fc898cee2f4886ed18ddf6271ec522e8 (diff)
parent989ac0b2635443b9c0f183ee6343b663c854f4ea (diff)
downloadocaml-ephemeron.tar.gz
merge with trunk at rev 14512ephemeron
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/ephemeron@14514 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
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