diff options
Diffstat (limited to 'otherlibs/unix/ftruncate.c')
-rw-r--r-- | otherlibs/unix/ftruncate.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/otherlibs/unix/ftruncate.c b/otherlibs/unix/ftruncate.c index f539a6450..5b401fde0 100644 --- a/otherlibs/unix/ftruncate.c +++ b/otherlibs/unix/ftruncate.c @@ -24,15 +24,22 @@ CAMLprim value unix_ftruncate(value fd, value len) { - if (ftruncate(Int_val(fd), Long_val(len)) == -1) - uerror("ftruncate", Nothing); + int result; + caml_enter_blocking_section(); + result = ftruncate(Int_val(fd), Long_val(len)); + caml_leave_blocking_section(); + if (result == -1) uerror("ftruncate", Nothing); return Val_unit; } CAMLprim value unix_ftruncate_64(value fd, value len) { - if (ftruncate(Int_val(fd), File_offset_val(len)) == -1) - uerror("ftruncate", Nothing); + int result; + file_offset ofs = File_offset_val(len); + caml_enter_blocking_section(); + result = ftruncate(Int_val(fd), ofs); + caml_leave_blocking_section(); + if (result == -1) uerror("ftruncate", Nothing); return Val_unit; } |