Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Sys_error("Bad file descriptor")
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: IKEDA Katsumi <ikeda@m...>
Subject: [Caml-list] Sys_error("Bad file descriptor")
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