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 B9EAA7F747 for ; Mon, 18 Aug 2014 19:18:36 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of thomas.braibant@gmail.com) identity=pra; client-ip=74.125.82.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="thomas.braibant@gmail.com"; x-sender="thomas.braibant@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of thomas.braibant@gmail.com designates 74.125.82.171 as permitted sender) identity=mailfrom; client-ip=74.125.82.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="thomas.braibant@gmail.com"; x-sender="thomas.braibant@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-we0-f171.google.com) identity=helo; client-ip=74.125.82.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="thomas.braibant@gmail.com"; x-sender="postmaster@mail-we0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8CADs08lNKfVKrlWdsb2JhbABZg2BXBIJ4r0+EM5QfgWOHWAGBGAgWEAEBAQEHDQkJEiuEAwEBAQMBEhEdARsSCwEDAQsGBQQHDQ0dAgIiAREBBQEKEgYTEhCICwEDCQgNn25riyuBcoMQihUKGScDCmaETREBBQ6POgQHgnmBUwWFBAWNF4MrhneBV5E6GCmFEDsvgk8BAQE X-IPAS-Result: Ah8CADs08lNKfVKrlWdsb2JhbABZg2BXBIJ4r0+EM5QfgWOHWAGBGAgWEAEBAQEHDQkJEiuEAwEBAQMBEhEdARsSCwEDAQsGBQQHDQ0dAgIiAREBBQEKEgYTEhCICwEDCQgNn25riyuBcoMQihUKGScDCmaETREBBQ6POgQHgnmBUwWFBAWNF4MrhneBV5E6GCmFEDsvgk8BAQE X-IronPort-AV: E=Sophos;i="5.01,887,1400018400"; d="scan'208";a="89737510" Received: from mail-we0-f171.google.com ([74.125.82.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Aug 2014 19:18:36 +0200 Received: by mail-we0-f171.google.com with SMTP id p10so5288306wes.30 for ; Mon, 18 Aug 2014 10:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/SAqxRU9SH6b6XFhsz1QqLaw1KQdj9umxKDFW/zYN+4=; b=Wqs3DfQxSHDMtj0gRzK7bhEpyjj9WGpxnMGmvjrVeFFwGigYGnSctJFwnVukWQsQHy SRFA7eWAhULevmYj6LMCsD+FpSaiskLL6SRTluuJe8Z+pHn7qLuBx6mBHStW5WTdc37w SyDm3KoG/bFrKIF2XObGRg2yRWU0huJ32YWK3CdyY6EFLgLj5hroJKC1GMrXIBKrd3fA PLi07fkF2womOw2atE8sy46e8Yi6Xgq2T/XG5oiXm01X8B9vsj0yaRDx4F9++TDyuv1E f9m9mm3CzrgliMyDQxdCYFA11zBemKR42u29NgNS03XDFB3Im/PP1NDFOzEykBQL9RfW 3vkg== MIME-Version: 1.0 X-Received: by 10.194.22.166 with SMTP id e6mr44439920wjf.88.1408382315757; Mon, 18 Aug 2014 10:18:35 -0700 (PDT) Received: by 10.194.9.226 with HTTP; Mon, 18 Aug 2014 10:18:35 -0700 (PDT) Received: by 10.194.9.226 with HTTP; Mon, 18 Aug 2014 10:18:35 -0700 (PDT) In-Reply-To: <53F2308C.9060908@inria.fr> References: <53F22AEB.5070506@inria.fr> <53F2308C.9060908@inria.fr> Date: Mon, 18 Aug 2014 19:18:35 +0200 Message-ID: From: Thomas Braibant To: Xavier Leroy Cc: OCaML Mailing List Content-Type: multipart/alternative; boundary=047d7b5d9127a389900500ea8f9a Subject: Re: [Caml-list] Unix file descriptors vs. in/out channels --047d7b5d9127a389900500ea8f9a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ah, my bad, sorry for the noise! Le 18 ao=C3=BBt 2014 18:58, "Xavier Leroy" a =C3=A9= crit : > 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. > > - 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 > --047d7b5d9127a389900500ea8f9a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Ah, my bad, sorry for the noise!

Le 18 ao=C3=BBt 2014 18:58, "Xavier Leroy&q= uot; <Xavier.Leroy@inria.fr= > a =C3=A9crit :
On 18/08/14 18:52, Thomas Braibant wrote:

> Well, I was thinking about the following situation
>
>=C2=A0 =C2=A0let open Unix in
>=C2=A0 =C2=A0let fd =3D openfile "foo.bar" [O_RDWR; O_TRUNC; = O_CREAT] 0o640 in
>=C2=A0 =C2=A0let o =3D out_channel_of_descr fd in
>=C2=A0 =C2=A0let i =3D in_channel_of_descr fd in
>=C2=A0 =C2=A0let i2 =3D in_channel_of_descr fd in
>=C2=A0 =C2=A0Printf.printf "1\n%!";
>=C2=A0 =C2=A0close_in i;
>=C2=A0 =C2=A0Printf.printf "2\n%!";
>=C2=A0 =C2=A0close_in i2;
>=C2=A0 =C2=A0Printf.printf "3\n%!";
>=C2=A0 =C2=A0close_out o;
>=C2=A0 =C2=A0Printf.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<= br> underlying file descriptor".=C2=A0 What you observe is that after the = first
close_in, all the other channels are unusable, because the underlying
FD is closed.

- Xavier Leroy

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
ht= tps://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
--047d7b5d9127a389900500ea8f9a--