summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/rename.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/rename.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/rename.c')
-rw-r--r--otherlibs/unix/rename.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/otherlibs/unix/rename.c b/otherlibs/unix/rename.c
index 2d34a8833..e63a06e36 100644
--- a/otherlibs/unix/rename.c
+++ b/otherlibs/unix/rename.c
@@ -13,11 +13,24 @@
#include <stdio.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_rename(value path1, value path2)
{
- if (rename(String_val(path1), String_val(path2)) == -1)
+ CAMLparam2(path1, path2);
+ char * p1;
+ char * p2;
+ int ret;
+ p1 = caml_stat_alloc_string(path1);
+ p2 = caml_stat_alloc_string(path2);
+ caml_enter_blocking_section();
+ ret = rename(p1, p2);
+ caml_leave_blocking_section();
+ caml_stat_free(p2);
+ caml_stat_free(p1);
+ if (ret == -1)
uerror("rename", path1);
- return Val_unit;
+ CAMLreturn(Val_unit);
}