close t
flushes and closes t
, and may raise an exception. close
returns () and
does not raise if t
is already closed. close
raises an exception if the close()
system call on the underlying file descriptor fails (i.e. returns -1), which would
happen in the following cases:
EBADF -- this would happen if someone else did close() system call on the underlying fd, which I would think a rare event.
EINTR -- would happen if the system call was interrupted by a signal, which would be
rare. Also, I think we should probably just catch EINTR and re-attempt the close.
Unfortunately, we can't do that in OCaml because the OCaml library marks the
out_channel as closed even if the close syscall fails, so a subsequent call
close_out_channel
will be a no-op. This should really be fixed in the OCaml library
C code, having it restart the close() syscall on EINTR. I put a couple CRs in
fixed_close_channel
, our rework of OCaml's caml_ml_close_channel
,
EIO -- I don't recall seeing this. I think it's rare.
See "man 2 close" for details.
Outputs a list of lines, each terminated by a newline character