caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Sys_error "Bad file descriptor"
@ 2001-04-09  9:08 wester
  0 siblings, 0 replies; 3+ messages in thread
From: wester @ 2001-04-09  9:08 UTC (permalink / raw)
  To: caml-list

Hi,

I try to open a file with append mode. Opening and writing to the file 
works but when I try to flush or close the file I get an error message:

let h_out = open_out_gen ~mode:[Open_append; Open_creat] ~perm:666 "f1.txt";;
Printf.fprintf h_out "%s" "something";;
close_out h_out;;

Uncaught exception: Sys_error "Bad file descriptor".

I'm running OCaml 3.1 on Windows NT 4.0. Any help is appreciated.

Rolf Wester  
-------------------------------------
Rolf Wester
wester@ilt.fhg.de
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread
* [Caml-list] Sys_error("Bad file descriptor")
@ 2002-11-11  2:31 IKEDA Katsumi
  2002-11-12  8:49 ` IKEDA Katsumi
  0 siblings, 1 reply; 3+ messages in thread
From: IKEDA Katsumi @ 2002-11-11  2:31 UTC (permalink / raw)
  To: caml-list

Hi, 

I make my log class the following.

---------------- pslog.ml ----------------
(* pslog.ml *)
class log =
  object
  val mutable out = stderr
  method log_open name =
      out <- open_out_gen [Open_append;Open_creat] 0o666 name;
  method log_close = close_out out
  method write mes =
      output_string out mes; flush out;
end
---------------- pslog.ml ----------------


I use on Debian GNU/Linux 3.0 :
    mylog#log_open(/var/tmp/mylog);
    mylog#write("program start\n");

Then the following error occurred.

  Fatal error: exception Sys_error("Bad file descriptor")


On FreeBSD 4.5, same error occurred.
On Red Hat Linux 7.2, no error occurred.

I change 
      out <- open_out_gen [Open_append;Open_creat] 0o666 name;
into
      out <- open_out name;
then program works well.

When I write in my pslog.ml --
  Printf.printf "out = %d\n" (Obj.magic out); flush stdout;
same value is printed.

What is wrong?

Thanks.

-- 
IKEDA Katsumi  <ikeda@msi.co.jp>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-12  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-09  9:08 [Caml-list] Sys_error "Bad file descriptor" wester
2002-11-11  2:31 [Caml-list] Sys_error("Bad file descriptor") IKEDA Katsumi
2002-11-12  8:49 ` IKEDA Katsumi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).