summaryrefslogtreecommitdiff
path: root/otherlibs
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
parent61a4334e2731d2a526a74e13db425297e633ef3f (diff)
downloadocaml-9fd3c41247589d58458fa269debde17b3a15e63e.tar.gz
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')
-rw-r--r--otherlibs/unix/access.c10
-rw-r--r--otherlibs/unix/chdir.c12
-rw-r--r--otherlibs/unix/chmod.c12
-rw-r--r--otherlibs/unix/chown.c12
-rw-r--r--otherlibs/unix/chroot.c12
-rw-r--r--otherlibs/unix/close.c7
-rw-r--r--otherlibs/unix/closedir.c7
-rw-r--r--otherlibs/unix/gethost.c3
-rw-r--r--otherlibs/unix/link.c17
-rw-r--r--otherlibs/unix/mkdir.c14
-rw-r--r--otherlibs/unix/mkfifo.c26
-rw-r--r--otherlibs/unix/open.c3
-rw-r--r--otherlibs/unix/opendir.c13
-rw-r--r--otherlibs/unix/readdir.c3
-rw-r--r--otherlibs/unix/readlink.c12
-rw-r--r--otherlibs/unix/rename.c17
-rw-r--r--otherlibs/unix/rmdir.c14
-rw-r--r--otherlibs/unix/stat.c49
-rw-r--r--otherlibs/unix/symlink.c17
-rw-r--r--otherlibs/unix/truncate.c26
-rw-r--r--otherlibs/unix/unlink.c14
-rw-r--r--otherlibs/unix/utimes.c26
22 files changed, 273 insertions, 53 deletions
diff --git a/otherlibs/unix/access.c b/otherlibs/unix/access.c
index 3a612a3406..6e91ba66ff 100644
--- a/otherlibs/unix/access.c
+++ b/otherlibs/unix/access.c
@@ -13,6 +13,8 @@
#include <mlvalues.h>
#include <alloc.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
#ifdef HAS_UNISTD
@@ -40,11 +42,17 @@ static int access_permission_table[] = {
CAMLprim value unix_access(value path, value perms)
{
+ CAMLparam2(path, perms);
+ char * p;
int ret, cv_flags;
cv_flags = convert_flag_list(perms, access_permission_table);
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
ret = access(String_val(path), cv_flags);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1)
uerror("access", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/chdir.c b/otherlibs/unix/chdir.c
index e7ea6f5058..4b93b5fc80 100644
--- a/otherlibs/unix/chdir.c
+++ b/otherlibs/unix/chdir.c
@@ -12,12 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_chdir(value path)
{
+ CAMLparam1(path);
+ char * p;
int ret;
- ret = chdir(String_val(path));
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = chdir(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("chdir", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/chmod.c b/otherlibs/unix/chmod.c
index ed2e88c8d7..a042155211 100644
--- a/otherlibs/unix/chmod.c
+++ b/otherlibs/unix/chmod.c
@@ -14,12 +14,20 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_chmod(value path, value perm)
{
+ CAMLparam2(path, perm);
+ char * p;
int ret;
- ret = chmod(String_val(path), Int_val(perm));
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = chmod(p, Int_val(perm));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("chmod", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/chown.c b/otherlibs/unix/chown.c
index a26f7a8690..0b118fb40a 100644
--- a/otherlibs/unix/chown.c
+++ b/otherlibs/unix/chown.c
@@ -12,12 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_chown(value path, value uid, value gid)
{
+ CAMLparam1(path);
+ char * p;
int ret;
- ret = chown(String_val(path), Int_val(uid), Int_val(gid));
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = chown(p, Int_val(uid), Int_val(gid));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("chown", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/chroot.c b/otherlibs/unix/chroot.c
index 02a46aedcf..7c9517c117 100644
--- a/otherlibs/unix/chroot.c
+++ b/otherlibs/unix/chroot.c
@@ -12,12 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_chroot(value path)
{
+ CAMLparam1(path);
+ char * p;
int ret;
- ret = chroot(String_val(path));
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = chroot(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("chroot", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/close.c b/otherlibs/unix/close.c
index 425502aac4..8a56c413b9 100644
--- a/otherlibs/unix/close.c
+++ b/otherlibs/unix/close.c
@@ -12,10 +12,15 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_close(value fd)
{
- if (close(Int_val(fd)) == -1) uerror("close", Nothing);
+ int ret;
+ caml_enter_blocking_section();
+ ret = close(Int_val(fd));
+ caml_leave_blocking_section();
+ if (ret == -1) uerror("close", Nothing);
return Val_unit;
}
diff --git a/otherlibs/unix/closedir.c b/otherlibs/unix/closedir.c
index ba9e743754..4196acd4e1 100644
--- a/otherlibs/unix/closedir.c
+++ b/otherlibs/unix/closedir.c
@@ -12,6 +12,8 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
#include <errno.h>
#include <sys/types.h>
@@ -23,9 +25,12 @@
CAMLprim value unix_closedir(value vd)
{
+ CAMLparam1(vd);
DIR * d = DIR_Val(vd);
if (d == (DIR *) NULL) unix_error(EBADF, "closedir", Nothing);
+ caml_enter_blocking_section();
closedir(d);
+ caml_leave_blocking_section();
DIR_Val(vd) = (DIR *) NULL;
- return Val_unit;
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c
index e155152f8f..607b6c35f8 100644
--- a/otherlibs/unix/gethost.c
+++ b/otherlibs/unix/gethost.c
@@ -127,8 +127,7 @@ CAMLprim value unix_gethostbyname(value name)
char * hostname;
#if HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT
- hostname = caml_stat_alloc(string_length(name) + 1);
- strcpy(hostname, String_val(name));
+ hostname = caml_stat_alloc_string(name);
#else
hostname = String_val(name);
#endif
diff --git a/otherlibs/unix/link.c b/otherlibs/unix/link.c
index b5051cd96e..8110bf5830 100644
--- a/otherlibs/unix/link.c
+++ b/otherlibs/unix/link.c
@@ -12,10 +12,23 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_link(value path1, value path2)
{
- if (link(String_val(path1), String_val(path2)) == -1) uerror("link", path2);
- return Val_unit;
+ 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 = link(p1, p2);
+ caml_leave_blocking_section();
+ caml_stat_free(p1);
+ caml_stat_free(p2);
+ if (ret == -1) uerror("link", path2);
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/mkdir.c b/otherlibs/unix/mkdir.c
index 0bb1f4f5fe..6a7bb18c24 100644
--- a/otherlibs/unix/mkdir.c
+++ b/otherlibs/unix/mkdir.c
@@ -14,10 +14,20 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_mkdir(value path, value perm)
{
- if (mkdir(String_val(path), Int_val(perm)) == -1) uerror("mkdir", path);
- return Val_unit;
+ CAMLparam2(path, perm);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = mkdir(p, Int_val(perm));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1) uerror("mkdir", path);
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/mkfifo.c b/otherlibs/unix/mkfifo.c
index ec3bed4bbd..ef440a25bc 100644
--- a/otherlibs/unix/mkfifo.c
+++ b/otherlibs/unix/mkfifo.c
@@ -15,15 +15,25 @@
#include <sys/stat.h>
#include <fail.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
#ifdef HAS_MKFIFO
CAMLprim value unix_mkfifo(value path, value mode)
{
- if (mkfifo(String_val(path), Int_val(mode)) == -1)
+ CAMLparam2(path, mode);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = mkfifo(p, Int_val(mode));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1)
uerror("mkfifo", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
#else
@@ -35,9 +45,17 @@ CAMLprim value unix_mkfifo(value path, value mode)
CAMLprim value unix_mkfifo(value path, value mode)
{
- if (mknod(String_val(path), (Int_val(mode) & 07777) | S_IFIFO, 0) == -1)
+ CAMLparam2(path, mode);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = mknod(p, (Int_val(mode) & 07777) | S_IFIFO, 0);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1)
uerror("mkfifo", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
#else
diff --git a/otherlibs/unix/open.c b/otherlibs/unix/open.c
index ecee013898..c98819aab4 100644
--- a/otherlibs/unix/open.c
+++ b/otherlibs/unix/open.c
@@ -62,8 +62,7 @@ CAMLprim value unix_open(value path, value flags, value perm)
char * p;
cv_flags = convert_flag_list(flags, open_flag_table);
- p = caml_stat_alloc(string_length(path) + 1);
- strcpy(p, String_val(path));
+ p = caml_stat_alloc_string(path);
/* open on a named FIFO can block (PR#1533) */
enter_blocking_section();
fd = open(p, cv_flags, Int_val(perm));
diff --git a/otherlibs/unix/opendir.c b/otherlibs/unix/opendir.c
index f70e708bdc..57a3318889 100644
--- a/otherlibs/unix/opendir.c
+++ b/otherlibs/unix/opendir.c
@@ -12,7 +12,9 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
#include <alloc.h>
+#include <signals.h>
#include "unixsupport.h"
#include <sys/types.h>
#ifdef HAS_DIRENT
@@ -23,11 +25,18 @@
CAMLprim value unix_opendir(value path)
{
+ CAMLparam1(path);
DIR * d;
value res;
- d = opendir(String_val(path));
+ char * p;
+
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ d = opendir(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (d == (DIR *) NULL) uerror("opendir", path);
res = alloc_small(1, Abstract_tag);
DIR_Val(res) = d;
- return res;
+ CAMLreturn(res);
}
diff --git a/otherlibs/unix/readdir.c b/otherlibs/unix/readdir.c
index 08dad1a06d..e6daf5f61c 100644
--- a/otherlibs/unix/readdir.c
+++ b/otherlibs/unix/readdir.c
@@ -14,6 +14,7 @@
#include <mlvalues.h>
#include <fail.h>
#include <alloc.h>
+#include <signals.h>
#include "unixsupport.h"
#include <errno.h>
#include <sys/types.h>
@@ -31,7 +32,9 @@ CAMLprim value unix_readdir(value vd)
directory_entry * e;
d = DIR_Val(vd);
if (d == (DIR *) NULL) unix_error(EBADF, "readdir", Nothing);
+ caml_enter_blocking_section();
e = readdir((DIR *) d);
+ caml_leave_blocking_section();
if (e == (directory_entry *) NULL) raise_end_of_file();
return copy_string(e->d_name);
}
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
diff --git a/otherlibs/unix/rename.c b/otherlibs/unix/rename.c
index 2d34a8833f..e63a06e364 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);
}
diff --git a/otherlibs/unix/rmdir.c b/otherlibs/unix/rmdir.c
index 631b47c0e3..28cef33d8f 100644
--- a/otherlibs/unix/rmdir.c
+++ b/otherlibs/unix/rmdir.c
@@ -12,10 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_rmdir(value path)
{
- if (rmdir(String_val(path)) == -1) uerror("rmdir", path);
- return Val_unit;
+ CAMLparam1(path);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = rmdir(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1) uerror("rmdir", path);
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/stat.c b/otherlibs/unix/stat.c
index a0f4c343d9..9825802a0a 100644
--- a/otherlibs/unix/stat.c
+++ b/otherlibs/unix/stat.c
@@ -15,6 +15,7 @@
#include <mlvalues.h>
#include <memory.h>
#include <alloc.h>
+#include <signals.h>
#include "unixsupport.h"
#include "cst2constr.h"
#include <sys/types.h>
@@ -70,35 +71,49 @@ static value stat_aux(int use_64, struct stat *buf)
CAMLprim value unix_stat(value path)
{
+ CAMLparam1(path);
int ret;
struct stat buf;
- ret = stat(String_val(path), &buf);
+ char * p;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = stat(p, &buf);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("stat", path);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "stat", path);
- return stat_aux(0, &buf);
+ CAMLreturn(stat_aux(0, &buf));
}
CAMLprim value unix_lstat(value path)
{
+ CAMLparam1(path);
int ret;
struct stat buf;
+ char * p;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
#ifdef HAS_SYMLINK
- ret = lstat(String_val(path), &buf);
+ ret = lstat(p, &buf);
#else
- ret = stat(String_val(path), &buf);
+ ret = stat(p, &buf);
#endif
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("lstat", path);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "lstat", path);
- return stat_aux(0, &buf);
+ CAMLreturn(stat_aux(0, &buf));
}
CAMLprim value unix_fstat(value fd)
{
int ret;
struct stat buf;
+ caml_enter_blocking_section();
ret = fstat(Int_val(fd), &buf);
+ caml_leave_blocking_section();
if (ret == -1) uerror("fstat", Nothing);
if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "fstat", Nothing);
@@ -107,31 +122,45 @@ CAMLprim value unix_fstat(value fd)
CAMLprim value unix_stat_64(value path)
{
+ CAMLparam1(path);
int ret;
struct stat buf;
- ret = stat(String_val(path), &buf);
+ char * p;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = stat(p, &buf);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("stat", path);
- return stat_aux(1, &buf);
+ CAMLreturn(stat_aux(1, &buf));
}
CAMLprim value unix_lstat_64(value path)
{
+ CAMLparam1(path);
int ret;
struct stat buf;
+ char * p;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
#ifdef HAS_SYMLINK
- ret = lstat(String_val(path), &buf);
+ ret = lstat(p, &buf);
#else
- ret = stat(String_val(path), &buf);
+ ret = stat(p, &buf);
#endif
+ caml_leave_blocking_section();
+ caml_stat_free(p);
if (ret == -1) uerror("lstat", path);
- return stat_aux(1, &buf);
+ CAMLreturn(stat_aux(1, &buf));
}
CAMLprim value unix_fstat_64(value fd)
{
int ret;
struct stat buf;
+ caml_enter_blocking_section();
ret = fstat(Int_val(fd), &buf);
+ caml_leave_blocking_section();
if (ret == -1) uerror("fstat", Nothing);
return stat_aux(1, &buf);
}
diff --git a/otherlibs/unix/symlink.c b/otherlibs/unix/symlink.c
index 26c9aa43ce..41ba020190 100644
--- a/otherlibs/unix/symlink.c
+++ b/otherlibs/unix/symlink.c
@@ -13,15 +13,28 @@
#include <fail.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
#ifdef HAS_SYMLINK
CAMLprim value unix_symlink(value path1, value path2)
{
- if (symlink(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 = symlink(p1, p2);
+ caml_leave_blocking_section();
+ caml_stat_free(p1);
+ caml_stat_free(p2);
+ if (ret == -1)
uerror("symlink", path2);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
#else
diff --git a/otherlibs/unix/truncate.c b/otherlibs/unix/truncate.c
index 638ef79947..5165e21fba 100644
--- a/otherlibs/unix/truncate.c
+++ b/otherlibs/unix/truncate.c
@@ -13,7 +13,9 @@
#include <sys/types.h>
#include <mlvalues.h>
+#include <memory.h>
#include <fail.h>
+#include <signals.h>
#include <io.h>
#include "unixsupport.h"
#ifdef HAS_UNISTD
@@ -24,16 +26,32 @@
CAMLprim value unix_truncate(value path, value len)
{
- if (truncate(String_val(path), Long_val(len)) == -1)
+ CAMLparam2(path, len);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = truncate(p, Long_val(len));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1)
uerror("truncate", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
CAMLprim value unix_truncate_64(value path, value len)
{
- if (truncate(String_val(path), File_offset_val(len)) == -1)
+ CAMLparam2(path, len);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = truncate(p, File_offset_val(len));
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1)
uerror("truncate", path);
- return Val_unit;
+ CAMLreturn(Val_unit);
}
#else
diff --git a/otherlibs/unix/unlink.c b/otherlibs/unix/unlink.c
index 76ec913109..4a4a513e39 100644
--- a/otherlibs/unix/unlink.c
+++ b/otherlibs/unix/unlink.c
@@ -12,10 +12,20 @@
/***********************************************************************/
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
CAMLprim value unix_unlink(value path)
{
- if (unlink(String_val(path)) == -1) uerror("unlink", path);
- return Val_unit;
+ CAMLparam1(path);
+ char * p;
+ int ret;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = unlink(p);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1) uerror("unlink", path);
+ CAMLreturn(Val_unit);
}
diff --git a/otherlibs/unix/utimes.c b/otherlibs/unix/utimes.c
index 825fc4cdfe..bb84c43e50 100644
--- a/otherlibs/unix/utimes.c
+++ b/otherlibs/unix/utimes.c
@@ -13,6 +13,8 @@
#include <fail.h>
#include <mlvalues.h>
+#include <memory.h>
+#include <signals.h>
#include "unixsupport.h"
#ifdef HAS_UTIME
@@ -26,15 +28,23 @@
CAMLprim value unix_utimes(value path, value atime, value mtime)
{
+ CAMLparam3(path, atime, mtime);
struct utimbuf times, * t;
+ char * p;
+ int ret;
times.actime = Double_val(atime);
times.modtime = Double_val(mtime);
if (times.actime || times.modtime)
t = &times;
else
t = (struct utimbuf *) NULL;
- if (utime(String_val(path), t) == -1) uerror("utimes", path);
- return Val_unit;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = utime(p, t);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1) uerror("utimes", path);
+ CAMLreturn(Val_unit);
}
#else
@@ -46,7 +56,10 @@ CAMLprim value unix_utimes(value path, value atime, value mtime)
CAMLprim value unix_utimes(value path, value atime, value mtime)
{
+ CAMLparam3(path, atime, mtime);
struct timeval tv[2], * t;
+ char * p;
+ int ret;
double at = Double_val(atime);
double mt = Double_val(mtime);
tv[0].tv_sec = at;
@@ -57,8 +70,13 @@ CAMLprim value unix_utimes(value path, value atime, value mtime)
t = tv;
else
t = (struct timeval *) NULL;
- if (utimes(String_val(path), t) == -1) uerror("utimes", path);
- return Val_unit;
+ p = caml_stat_alloc_string(path);
+ caml_enter_blocking_section();
+ ret = utimes(p, t);
+ caml_leave_blocking_section();
+ caml_stat_free(p);
+ if (ret == -1) uerror("utimes", path);
+ CAMLreturn(Val_unit);
}
#else