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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id ED82E7F747 for ; Mon, 18 Aug 2014 19:55:45 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of kosmo.zb@gmail.com) identity=pra; client-ip=209.85.215.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of kosmo.zb@gmail.com designates 209.85.215.52 as permitted sender) identity=mailfrom; client-ip=209.85.215.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-la0-f52.google.com) identity=helo; client-ip=209.85.215.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="postmaster@mail-la0-f52.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcCAMU98lPRVdc0m2dsb2JhbABZg2BXBIJ4r08Hmi6HWIEaCBYQAQEBAQEGCwsJFCmEBAEBBBIRHQEtCwEDDAEFBQsNAgIJHQICIQESAQUBChIGExIQiAwDEQ2gAWuLK4UCijsnAwpXhFwRAQUOgR6Lc4F6gzOBUwWFBAWQQoRogg+BV4x5hEEYKYFrgyQ8L4JPAQEB X-IPAS-Result: AtcCAMU98lPRVdc0m2dsb2JhbABZg2BXBIJ4r08Hmi6HWIEaCBYQAQEBAQEGCwsJFCmEBAEBBBIRHQEtCwEDDAEFBQsNAgIJHQICIQESAQUBChIGExIQiAwDEQ2gAWuLK4UCijsnAwpXhFwRAQUOgR6Lc4F6gzOBUwWFBAWQQoRogg+BV4x5hEEYKYFrgyQ8L4JPAQEB X-IronPort-AV: E=Sophos;i="5.01,887,1400018400"; d="scan'208";a="89740351" Received: from mail-la0-f52.google.com ([209.85.215.52]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Aug 2014 19:55:45 +0200 Received: by mail-la0-f52.google.com with SMTP id b17so4849149lan.39 for ; Mon, 18 Aug 2014 10:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=5ZmKg7Owc2VsecCLQmtBQ7ATUe8EEoSuBNNoRlwINxk=; b=ue0jTW6oWCbgYBO0wpa/uCv81pjEY52yuUVIbpJhygMAJHhmD3rdeq8kSxaPa277Qo btI/TX8w4azLP0Ur4WRp8sQgkru11DP+liQcLDUeOA2boPikgmHWPRMsGu22HFyoRD6v +JaEnxRlMG/0LxHT8qmqgCio3ECj+FfRoseVS/QvN3qeKU4RNdhRYPvVChRoSwLJYoTj abxbhZe9emn1Ywb94IRvqRhVvLg5jD2Fbk8O8LMJQ40WTnj0kU+bxn+oFtc4bRk4CeRj 3zDCcNPWRudWsNECBQZpVBBlzEJDBOjo5WJHAA1iwjtgfn88FSVk0IjS+UWUUbDBLW2F cAVw== MIME-Version: 1.0 X-Received: by 10.112.30.39 with SMTP id p7mr29445301lbh.35.1408384544545; Mon, 18 Aug 2014 10:55:44 -0700 (PDT) Sender: kosmo.zb@gmail.com Received: by 10.112.157.166 with HTTP; Mon, 18 Aug 2014 10:55:44 -0700 (PDT) In-Reply-To: References: <53F22AEB.5070506@inria.fr> <53F2308C.9060908@inria.fr> Date: Mon, 18 Aug 2014 18:55:44 +0100 X-Google-Sender-Auth: CuldVDnbJZmDCv3DHxsD1umf1Dc Message-ID: From: David Sheets To: Thomas Braibant Cc: Xavier Leroy , OCaML Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Unix file descriptors vs. in/out channels On Mon, Aug 18, 2014 at 6:18 PM, Thomas Braibant wrote: > Ah, my bad, sorry for the noise! > > Le 18 ao=C3=BBt 2014 18:58, "Xavier Leroy" a =C3= =A9crit : > >> On 18/08/14 18:52, Thomas Braibant wrote: >> >> > Well, I was thinking about the following situation >> > >> > let open Unix in >> > let fd =3D openfile "foo.bar" [O_RDWR; O_TRUNC; O_CREAT] 0o640 in >> > let o =3D out_channel_of_descr fd in >> > let i =3D in_channel_of_descr fd in >> > let i2 =3D 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. I'm sorry. I still don't understand. The following raises on the first clos= e_in: let open Unix in let fd =3D openfile "foo.bar" [O_RDWR; O_TRUNC; O_CREAT] 0o640 in let o =3D out_channel_of_descr fd in let i =3D in_channel_of_descr fd in let i2 =3D in_channel_of_descr fd in Printf.printf "1\n%!"; close_out o; close_in i; close_in i2; Printf.printf "Ok\n%!" To get the error ignoring property, I think you have to use close_out_noerr (not in this case) and close_in_noerr. Maybe I've missed some subtlety here, though. I'm a little uneasy ignoring *all* errors... David >> - Xavier Leroy >> >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa.inria.fr/sympa/arc/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs