From owner-freebsd-hackers@freebsd.org Fri Jan 5 22:18:15 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3923EC42B1 for ; Fri, 5 Jan 2018 22:18:15 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [78.47.246.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 6B6021C83; Fri, 5 Jan 2018 22:18:14 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (root@eg.sd.rdtc.ru [62.231.161.221] (may be forged)) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id w05MHxRn041958 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Jan 2018 23:18:00 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: brooks@freebsd.org Received: from [10.58.0.4] ([10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id w05MHtNE019435 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 6 Jan 2018 05:17:55 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? To: Brooks Davis , Alan Somers References: <24acbd94-c52f-e71a-8a96-d608a10963c6@rawbw.com> <1514572041.12000.7.camel@freebsd.org> <20180105221330.GD95035@spindle.one-eyed-alien.net> Cc: Yuri , Ian Lepore , Freebsd hackers list From: Eugene Grosbein Message-ID: <5A4FF989.1040709@grosbein.net> Date: Sat, 6 Jan 2018 05:17:45 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20180105221330.GD95035@spindle.one-eyed-alien.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WaX0PKN5PUEovsUibQhwjaF1BhrNSms3T" X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00, LOCAL_FROM, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 2.6 LOCAL_FROM From my domains * 1.9 RDNS_NONE Delivered to internal network by a host with no rDNS X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hz.grosbein.net X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 22:18:15 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WaX0PKN5PUEovsUibQhwjaF1BhrNSms3T Content-Type: multipart/mixed; boundary="9s0LvRWHs38dRhcArdcFTcnu7qtmMJMoq"; protected-headers="v1" From: Eugene Grosbein To: Brooks Davis , Alan Somers Cc: Yuri , Ian Lepore , Freebsd hackers list Message-ID: <5A4FF989.1040709@grosbein.net> Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? References: <24acbd94-c52f-e71a-8a96-d608a10963c6@rawbw.com> <1514572041.12000.7.camel@freebsd.org> <20180105221330.GD95035@spindle.one-eyed-alien.net> In-Reply-To: <20180105221330.GD95035@spindle.one-eyed-alien.net> --9s0LvRWHs38dRhcArdcFTcnu7qtmMJMoq Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 06.01.2018 5:13, Brooks Davis wrote: >> I would argue the opposite. There are very few reasons why close(s) w= ould >> ever fail, and the most likely is EBADF. EBADF indicates a programmin= g >> bug, like a double close or use of an uninitialized variable. Those c= ould >> easily turn into worse bugs in the future. So I think the best course= of >> action is to check the return code, assert() on EBADF, and ignore, or >> possibly log, other errors. >=20 > For this specific case, I think there would be value in an option to > have the kernel kill any process that calls close(fd) where fd !=3D -1 > where EBADF would be returned. A medicine should not be worse worse than the disease, imho. --9s0LvRWHs38dRhcArdcFTcnu7qtmMJMoq-- --WaX0PKN5PUEovsUibQhwjaF1BhrNSms3T Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJaT/mPAAoJELDNGvImmIsoJo0IAIqmmum8PyLuAvK7B9HFVu1c hQxA+avmB4NwqeyZhe1U6i+IqcGvIM1zrVkCje7eAqBbHEbSO7i5zmvI11warxPx 2JFQ1oayQQ26xILPgOb7kwdsIMb4RuTWa3F7EU2kszO8o3C8K1EpPTuLhpD3T2eU +LWOchaZJrMP7OSBo/b4OmyUKdmqv35674x8qR6ApgViFxABblW42vlN9wuvlPl0 30/jFG8hXFH3lq4sv9RGzKcU5u8Jyl6JtmucsRsYx5HFOhgj0SXWCkpkZ0FWEGLF TeBTDgxSPBWxqMEzzRKeoNhFH9prPB5m0kwlyMwCGckdBlSYSAStYAQyqzu3c+w= =ezxP -----END PGP SIGNATURE----- --WaX0PKN5PUEovsUibQhwjaF1BhrNSms3T--