summaryrefslogtreecommitdiffstats
path: root/byterun/sys.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2007-02-25 12:38:36 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2007-02-25 12:38:36 +0000
commit160e4050d82aa38be7f68dd33e4b82b86f09ab39 (patch)
tree1c50e3e43bc46bf050ec47183f4c5ee7ddfcff5f /byterun/sys.c
parente254ca38e003e7fa3b0989a706d4605bdcd47382 (diff)
Raise Sys_blocked_io only in I/O operations that return EAGAIN/EWOULDBLOCK. Other, non-I/O related system calls can also return EAGAIN (e.g. in Sys.command); these should raise Sys_error, not Sys_blocked_io
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7919 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/sys.c')
-rw-r--r--byterun/sys.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/byterun/sys.c b/byterun/sys.c
index 9d3bedbbb..801b1303b 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -73,23 +73,28 @@ CAMLexport void caml_sys_error(value arg)
char * err;
CAMLlocal1 (str);
+ err = error_message();
+ if (arg == NO_ARG) {
+ str = caml_copy_string(err);
+ } else {
+ int err_len = strlen(err);
+ int arg_len = caml_string_length(arg);
+ str = caml_alloc_string(arg_len + 2 + err_len);
+ memmove(&Byte(str, 0), String_val(arg), arg_len);
+ memmove(&Byte(str, arg_len), ": ", 2);
+ memmove(&Byte(str, arg_len + 2), err, err_len);
+ }
+ caml_raise_sys_error(str);
+ CAMLnoreturn;
+}
+
+CAMLexport void caml_sys_io_error(value arg)
+{
if (errno == EAGAIN || errno == EWOULDBLOCK) {
caml_raise_sys_blocked_io();
} else {
- err = error_message();
- if (arg == NO_ARG) {
- str = caml_copy_string(err);
- } else {
- int err_len = strlen(err);
- int arg_len = caml_string_length(arg);
- str = caml_alloc_string(arg_len + 2 + err_len);
- memmove(&Byte(str, 0), String_val(arg), arg_len);
- memmove(&Byte(str, arg_len), ": ", 2);
- memmove(&Byte(str, arg_len + 2), err, err_len);
- }
- caml_raise_sys_error(str);
+ caml_sys_error(arg);
}
- CAMLnoreturn;
}
CAMLprim value caml_sys_exit(value retcode)