[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: [Caml-list] using open_out_gen, output_string and close_out |
> The following illustrates my problem: > ------------------------------- > $ocaml > Objective Caml version 3.00 > > # let l = open_out_gen [Open_creat;Open_append] 0o666 "/tmp/xx";; > val l : out_channel = <abstr> > # close_out l;; > - : unit = () > # let l = open_out_gen [Open_creat;Open_append] 0o666 "/tmp/xx";; > val l : out_channel = <abstr> > # output_string l "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb > ccccccccccccccccccccccccccccccccc";; > - : unit = () > # close_out l;; > Uncaught exception: Sys_error "Bad file descriptor". The Open_append flag does not imply write access, it's just a modifier saying "whatever writes you do, do them at the end of the file". So you need to specify Open_wronly as well. (Agreed, the documentation should state this.) Otherwise, as you found out, actual writes to the file will fail. (Since output is buffered, the "output_string" didn't perform an actual write to the file, hence no error, but "close_out" flushes the buffer to the file, hence the error pops up at that time.) - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr