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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 71D67BC69 for ; Fri, 14 Sep 2007 23:51:35 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACKf6kbAbSoIk2dsb2JhbACOEQEBAgcEBgcg X-IronPort-AV: E=Sophos;i="4.20,257,1186351200"; d="scan'208";a="1218236" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2007 23:52:11 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l8ELpopa029555 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 14 Sep 2007 23:51:51 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACKf6kbAbSoIk2dsb2JhbACOEQEBAgcEBgcg X-IronPort-AV: E=Sophos;i="4.20,257,1186351200"; d="scan'208";a="1218235" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2007 23:52:10 +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 l8ELq9Ls023755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Sep 2007 23:52:09 +0200 Received: (from www-data@localhost) by einhorn.in-berlin.de (8.13.6/8.13.6/Submit) id l8ELq8UU023753 for caml-list@inria.fr; Fri, 14 Sep 2007 23:52:08 +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-114-000.pools.arcor-ip.net (dslb-088-073-114-000.pools.arcor-ip.net [88.73.114.0]) by webmail.in-berlin.de (IMP) with HTTP for ; Fri, 14 Sep 2007 23:52:08 +0200 Message-ID: <1189806728.46eb0288d38b8@webmail.in-berlin.de> Date: Fri, 14 Sep 2007 23:52:08 +0200 From: Oliver Bandel To: Caml List Subject: Re: [Caml-list] Closing all open file descriptors References: <006b01c7f699$275fd6d0$017ca8c0@countertenor> <200709141000.l8EA04x12648@virtutech.se> In-Reply-To: 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 discorde with ID 46EB0276.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 readdir:01 ocaml:01 ocaml:01 non-unix:01 2007,:98 wrote:01 unix:01 unix:01 oliver:01 oliver:01 abstract:01 Zitat von Dave Benjamin : > On Fri, 14 Sep 2007, Mattias EngdegÄrd wrote: > > >> Probably irrelevant here, but this approach wouldn't work under Windows > >> (Unix.file_descr is the Win32 file handle at that point which is often > >> larger than 1024). More relevantly, Unix can be reconfigured to allow for > >> more than 1024 open files. > > > > I think platform-dependent code is required here. The common way of > > doing this under Linux (and Solaris, probably) is to readdir > > /proc/PID/fd/. Windows is of course very different. > > I like this approach. It doesn't eliminate the need to convert ints to > descrs, On Unix, file-descriptors are identified by integer-values. In OCaml, you have abstract types for file-descriptors. So, how to convert them? I think, officially there is no way. But if you like the concept of completely using files, Plan9 as operating system would make sense to you. :) > but at least you don't have a bunch of unnecessary system calls or > a hard-coded maximum Something like Sys.max_open_fd would be fine, and I think there should be a way to make it cross-platform-available. > (assuming getrlimit is unavailable, as it is with > OCaml currently). getrlimit seems to be a Unix-only thing. I don't know if this is also available on other systems, like Windows or so. So, if it is Unix-specific, this only would make sense in the Unix-modlue. But something like the maximum number of open files / max-num of used filedescriptors would also make sense on unix. So, I would ask for something like a Sys.max_open_fd. This owuld be a cross-platform thing. > I wonder if /dev/fd is more or less portable... Will this be available on non-Unix and non-Linux systems? You also mentioned Win-systems? If you also need that portability, you should not look for Unix-only features. Ciao, Oliver