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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 1F6117ED1A for ; Mon, 21 May 2012 13:57:54 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au0CAPAsuk/U4xEKk2dsb2JhbAA6CqFpkhgiAQEBAQkJCwkUAySCFQEBBAE6NAsFJBddCRIGEwkJh24DBgkHtSgDiVwUinEPhT4DjSeJA5FM X-IronPort-AV: E=Sophos;i="4.75,631,1330902000"; d="scan'208";a="159160653" Received: from moutng.kundenserver.de ([212.227.17.10]) by mail1-smtp-roc.national.inria.fr with ESMTP; 21 May 2012 13:57:53 +0200 Received: from office1.lan.sumadev.de (dslb-084-059-076-247.pools.arcor-ip.net [84.59.76.247]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0LsywU-1S3SHw0p0U-012bRC; Mon, 21 May 2012 13:57:46 +0200 Received: from samsung (dslb-178-004-230-011.pools.arcor-ip.net [178.4.230.11]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id F0CAEC00D0; Mon, 21 May 2012 13:57:44 +0200 (CEST) Date: Mon, 21 May 2012 13:57:32 +0200 From: Gerd Stolpmann To: Lauri Alanko Cc: caml-list@inria.fr In-Reply-To: <20120521142336.79901oeoxunjuoc8.lealanko@webmail.helsinki.fi> (from la@iki.fi on Mon May 21 13:23:36 2012) X-Mailer: Balsa 2.4.11 Message-Id: <1337601452.19263.0@samsung> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:loetCjlMIKk0kseBKDULpM9TqjHAT7Ri4KyONgy/Gul stz2baA7+1+ZetxGK5CtdgdXiQPfFFTMD3yUCIYxNLt+bXolOP QFscbJjMA6Q4Iw5mGqPgGqyUpRZKVnfNgKnJSR131YdM4MCTV5 fIYn3OnRa3ETrjIUm2DsrIPvCbBLfJnH4MBX9ltw+ZfMO8Lexo fX6VOEyztiFK+AGP3roqSjVfLc/7T5Hl2OR6V5TAiYErkbga8w 8Gd3aaciE02i9TCA8j5o2gnYSSOTEAkM8KskE8wqnD2hFqDB+Y MjNsWyWkq+4mSqhz0RVdP/qwlnlHNl/KNmkKjZRvKNsZz41CKX mGQ7tZr6yIACG8sReCVU= Subject: AW: [Caml-list] Channels not closed on gc? Am 21.05.2012 13:23:36 schrieb(en) Lauri Alanko: > I only recently noticed that ocaml does not close open channels when=20= =20 > they are garbage collected. This is evidently intentional behavior,=20=20 > but it was quite unexpected. >=20 > To be clear, I do think it's bad style to rely on GC for releasing OS=20= =20 > resources, but that doesn't explain why GC shouldn't do this if the=20=20 > programmer has failed to explicitly close the channel. And if the=20=20 > intention were to _enforce_ good style, the channel finaliser would=20=20 > spout out an error or warning upon detecting that the channel hasn't=20= =20 > yet been closed, instead of just silently leaking file handles like=20=20 > it does currently. >=20 > It is of course trivial to "fix" this by attaching a simple=20=20 > finaliser, but the fact that this is not done by default makes me=20=20 > suspect that there would be something fishy with this approach. So,=20=20 > what's the rationale for the current behavior? It's predictable. Closing a channel is not only about releasing OS resources. Imagine the=20= =20 channel is actually a pipe - closing it means to signal EOF, i.e. it's=20= =20 a way of notifying another program about an event. This should not=20=20 happen behind one's back. Closing a regular file would in deed be harmless, but there is no=20=20 generic way to identify such channels (in the OS). Gerd > Thanks, >=20 >=20 > Lauri >=20 >=20 >=20 >--=20 > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------=