fix du fix du PR#1249

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5212 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2002-10-31 10:37:53 +00:00
parent 6df4c2b6de
commit 1ba3a292a9
3 changed files with 11 additions and 10 deletions

View File

@ -489,8 +489,12 @@ CAMLprim value caml_close_channel(value vchannel)
/* For output channels, must have flushed before */
struct channel * channel = Channel(vchannel);
result = close(channel->fd);
channel->fd = -1;
if (channel->fd != -1){
result = close(channel->fd);
channel->fd = -1;
}else{
result = 0;
}
/* Ensure that every read or write on the channel will cause an
immediate flush_partial or refill, thus raising a Sys_error
exception */

View File

@ -271,7 +271,7 @@ external seek_out : out_channel -> int -> unit = "caml_seek_out"
external pos_out : out_channel -> int = "caml_pos_out"
external out_channel_length : out_channel -> int = "caml_channel_size"
external close_out_channel : out_channel -> unit = "caml_close_channel"
let close_out oc = (try flush oc with _ -> ()); close_out_channel oc
let close_out oc = flush oc; close_out_channel oc
let close_out_noerr oc =
(try flush oc with _ -> ());
(try close_out_channel oc with _ -> ())

View File

@ -619,11 +619,10 @@ val close_out : out_channel -> unit
applied to a closed output channel, except [close_out] and [flush],
which do nothing when applied to an already closed channel.
Note that [close_out] may raise [Sys_error] if the operating
system signals an error when closing the underlying file descriptor. *)
system signals an error when flushing or closing. *)
val close_out_noerr : out_channel -> unit
(** Same as [close_out], but ignore all errors and never raise
[Sys_error]. *)
(** Same as [close_out], but ignore all errors. *)
val set_binary_mode_out : out_channel -> bool -> unit
(** [set_binary_mode_out oc true] sets the channel [oc] to binary
@ -727,12 +726,10 @@ val close_in : in_channel -> unit
exception when they are applied to a closed input channel,
except [close_in], which does nothing when applied to an already
closed channel. Note that [close_in] may raise [Sys_error] if
the operating system signals an error when closing the underlying
file descriptor. *)
the operating system signals an error. *)
val close_in_noerr : in_channel -> unit
(** Same as [close_in], but ignore any errors and never raise
[Sys_error]. *)
(** Same as [close_in], but ignore all errors. *)
val set_binary_mode_in : in_channel -> bool -> unit
(** [set_binary_mode_in ic true] sets the channel [ic] to binary