English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-11-12 (08:31)
From: IKEDA Katsumi <ikeda@m...>
Subject: [Caml-list] Sys_error("Bad file descriptor")

I make my log class the following.

---------------- pslog.ml ----------------
(* pslog.ml *)
class log =
  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;
---------------- pslog.ml ----------------

I use on Debian GNU/Linux 3.0 :
    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;
      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?


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