From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0303EBC69 for ; Sat, 15 Sep 2007 13:56:40 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGpl60bAXQInjWdsb2JhbACOEgEBAQEHBAYHHg X-IronPort-AV: E=Sophos;i="4.20,258,1186351200"; d="scan'208";a="814883" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Sep 2007 13:57:20 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l8FBuwEQ022509 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sat, 15 Sep 2007 13:56:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABRl60bAbSoIh2dsb2JhbACOEgEBAQgKJw X-IronPort-AV: E=Sophos;i="4.20,258,1186351200"; d="scan'208";a="16235821" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2007 13:57:19 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from einhorn.in-berlin.de (localhost [127.0.0.1]) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l8FBvIhg030351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 15 Sep 2007 13:57:18 +0200 Received: (from www-data@localhost) by einhorn.in-berlin.de (8.13.6/8.13.6/Submit) id l8FBvIcX030349 for caml-list@inria.fr; Sat, 15 Sep 2007 13:57:18 +0200 X-Authentication-Warning: einhorn.in-berlin.de: www-data set sender to oliver@first.in-berlin.de using -f Received: from dslb-088-073-095-014.pools.arcor-ip.net (dslb-088-073-095-014.pools.arcor-ip.net [88.73.95.14]) by webmail.in-berlin.de (IMP) with HTTP for ; Sat, 15 Sep 2007 13:57:17 +0200 Message-ID: <1189857437.46ebc89defff3@webmail.in-berlin.de> Date: Sat, 15 Sep 2007 13:57:17 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] Closing all open file descriptors References: <006b01c7f699$275fd6d0$017ca8c0@countertenor> <200709141000.l8EA04x12648@virtutech.se> <1189806728.46eb0288d38b8@webmail.in-berlin.de> <1189847741.46eba2bd9d121@webmail.in-berlin.de> <20070915192631.2384ae5a.mle+ocaml@mega-nerd.com> <1189852990.46ebb73e7edc3@webmail.in-berlin.de> <200709151136.l8FBaH813458@virtutech.se> In-Reply-To: <200709151136.l8FBaH813458@virtutech.se> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.6 X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 46EBC88A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 descriptors:01 mattias:01 mattias:01 descriptors:01 ocaml:01 ocaml:01 low-level:01 high-level:01 low-level:01 buffered:01 high-level:01 imho:01 imho:01 Zitat von Mattias EngdegÄ rd : > >If you have all your open descriptors in a list, > >you can close them after a fork. > > That approach does not compose well --- descriptors opened by > a library will be excluded. The only good way is to ask the system. > What do you mean with "does not compose well"? Do you see OCaml-specific problems here, or what? In C, there is a function fileno(3). Possibly this is, what people discussing in this thread are looking for. This would be a thing that could be included in Ocaml, but the result would not be an integer-value, because OCaml uses abstract types for file descriptors. And to have buffered-io streams together with abstract file descriptor-types and additionally having a integer-aequivalent of it, IMHO would be an emerging mess. When it is intended to make low-level handling of things with the Unix-functions, one would use Unix.open and not open_in or open_out, IMHO. And then the file-descriptors are already available. I'm a littlebid sceptical on using high-level and low-level stuff together. In C it's also not recommended to mix buffered and non-buffered IO, and so in OCaml, which is quite more high-level stuff, I would be even more sceptical on mixing these things together. As a general rule I would recommend, not to mix the different IO-possibilities. And that's a reason, why C-functions like fileno(3) are rarely used by myself. Ciao, Oliver