From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id F2D5D7F747 for ; Mon, 18 Aug 2014 18:57:48 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of Xavier.Leroy@inria.fr) identity=pra; client-ip=212.27.42.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="Xavier.Leroy@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of Xavier.Leroy@inria.fr) identity=mailfrom; client-ip=212.27.42.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="Xavier.Leroy@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp4-g21.free.fr) identity=helo; client-ip=212.27.42.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="postmaster@smtp4-g21.free.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkBAO4v8lPUGyoEnGdsb2JhbABZhzPOQIMcAYEgFhABAQEBAQYNCQkUKYQEAQQBIzAlBgsLGgIFFgsCAgkDAgECAUUGDQgBAYg2DKwRlR0XgSyOJ4J5gVMBBJxChyqROIM5AQEB X-IPAS-Result: AvkBAO4v8lPUGyoEnGdsb2JhbABZhzPOQIMcAYEgFhABAQEBAQYNCQkUKYQEAQQBIzAlBgsLGgIFFgsCAgkDAgECAUUGDQgBAYg2DKwRlR0XgSyOJ4J5gVMBBJxChyqROIM5AQEB X-IronPort-AV: E=Sophos;i="5.01,887,1400018400"; d="scan'208";a="75139398" Received: from smtp4-g21.free.fr ([212.27.42.4]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 18 Aug 2014 18:57:48 +0200 Received: from [192.168.1.2] (unknown [82.237.71.191]) by smtp4-g21.free.fr (Postfix) with ESMTP id 2A3744C80A7 for ; Mon, 18 Aug 2014 18:57:48 +0200 (CEST) Message-ID: <53F2308C.9060908@inria.fr> Date: Mon, 18 Aug 2014 18:57:48 +0200 From: Xavier Leroy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: OCaML Mailing List References: <53F22AEB.5070506@inria.fr> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Unix file descriptors vs. in/out channels On 18/08/14 18:52, Thomas Braibant wrote: > Well, I was thinking about the following situation > > let open Unix in > let fd = openfile "foo.bar" [O_RDWR; O_TRUNC; O_CREAT] 0o640 in > let o = out_channel_of_descr fd in > let i = in_channel_of_descr fd in > let i2 = in_channel_of_descr fd in > Printf.printf "1\n%!"; > close_in i; > Printf.printf "2\n%!"; > close_in i2; > Printf.printf "3\n%!"; > close_out o; > Printf.printf "Ok\n%!" > > that raises the fatal error: exception Sys_error("Bad file > descriptor"), and now, I do not understand your remark either :(. I said "close all your channels at once when you're done with the underlying file descriptor". What you observe is that after the first close_in, all the other channels are unusable, because the underlying FD is closed. - Xavier Leroy