summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/readlink.c
diff options
context:
space:
mode:
authorJérémie Dimino <jeremie@dimino.org>2013-12-23 16:24:50 +0000
committerJérémie Dimino <jeremie@dimino.org>2013-12-23 16:24:50 +0000
commit9fd3c41247589d58458fa269debde17b3a15e63e (patch)
treef2b13c73a9f847fd1b8f9c5d2f4ad2b25ce7bbc2 /otherlibs/unix/readlink.c
parent61a4334e2731d2a526a74e13db425297e633ef3f (diff)
fix #6276: release the runtime in all stubs that might block
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14384 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 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