From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Johann Spies <jhspies@adept.co.za>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] using open_out_gen, output_string and close_out
Date: Tue, 7 Aug 2001 09:36:50 +0200 [thread overview]
Message-ID: <20010807093650.A21319@pauillac.inria.fr> (raw)
In-Reply-To: <8766c12adu.fsf@adept.co.za>; from jhspies@adept.co.za on Mon, Aug 06, 2001 at 10:37:01PM +0200
> 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
next prev parent reply other threads:[~2001-08-07 7:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-06 20:37 Johann Spies
2001-08-07 7:36 ` Xavier Leroy [this message]
2001-08-07 10:46 ` Johann Spies
2001-08-07 0:36 Jeremy Fincher
2001-08-07 8:33 Johann Spies
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010807093650.A21319@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=jhspies@adept.co.za \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox