From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4D158BBBB for ; Fri, 17 Mar 2006 20:30:21 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k2HJUKe2009335 for ; Fri, 17 Mar 2006 20:30:20 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA29302 for ; Fri, 17 Mar 2006 20:30:20 +0100 (MET) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k2HJUJF4002964 for ; Fri, 17 Mar 2006 20:30:20 +0100 Received: from poincare (mathwifi.swapping.umh.ac.be [10.102.100.203]) by hedwig1.umh.ac.be (8.13.1/8.13.1) with ESMTP id k2HJXuBX319708; Fri, 17 Mar 2006 20:33:56 +0100 Received: from localhost ([127.0.0.1] ident=trch) by poincare with esmtp (Exim 4.60) (envelope-from ) id 1FKKeO-0007kV-HW; Fri, 17 Mar 2006 20:30:16 +0100 Date: Fri, 17 Mar 2006 20:30:16 +0100 (CET) Message-Id: <20060317.203016.231069790.debian00@tiscali.fr> To: OCaml Mailing List Subject: toplevel "I/O error: Bad file descriptor" loop From: Christophe TROESTLER X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoL KJBq0JBY9:}8v|j Organization: Universite de Mons-Hainaut (http://math.umh.ac.be/an/) X-Spook: SSL top secret anarchy embassy Mole EuroFed high security radar Croatian broadside X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Operating-System: GNU/Linux (http://www.linux.org/) X-Mailer-URL: http://www.mew.org/ X-Mailer: Mew version 4.2.53 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-j-chkmail-Score: MSGID : 441B0E4B.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 441B0E4C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 441B0E4B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; toplevel:01 christophe:01 troestler:01 bytecode:01 toplevel:01 val:01 abstr:01 stub:01 val:01 lstat:01 stdout:01 sourceforge:01 dev:01 exists:01 native:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=FROM_ENDS_IN_NUMS autolearn=disabled version=3.0.3 Hi, I have put together the following simple binding to libmagic: https://sourceforge.net/projects/ocaml-magic/ Everything works fine with bytecode and native code compiled programs but, when I try it in the toplevel to query a non existing file or a special device, I get a looping "I/O error: Bad file descriptor" message. Example: # let c = Magic.create [];; val c : Magic.t = # let m1 = Magic.file c "dllmagic_stub.so";; val m1 : string = "ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped" So far everything is fine. # let m3 = Magic.file c "/dev/null";; val m3 : string = "character special (1/3)" # I/O error: Bad file descriptor The last message is returned in a loop by the system. # let m4 = Magic.file c "xxx";; The same thing happens if "xxx" does not exists. Has anybody an idea where to look for the cause of this problem? I looked into libmagic code but the one dealing with file system magic (fsmagic.c) seems to only perform an unharmful stat/lstat and not touch stdout. Best regards, ChriS