Date: Sat, 6 Jan 2018 05:17:45 +0700 From: Eugene Grosbein <eugen@grosbein.net> To: Brooks Davis <brooks@freebsd.org>, Alan Somers <asomers@freebsd.org> Cc: Yuri <yuri@rawbw.com>, Ian Lepore <ian@freebsd.org>, Freebsd hackers list <freebsd-hackers@freebsd.org> Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? Message-ID: <5A4FF989.1040709@grosbein.net> In-Reply-To: <20180105221330.GD95035@spindle.one-eyed-alien.net> References: <24acbd94-c52f-e71a-8a96-d608a10963c6@rawbw.com> <1514572041.12000.7.camel@freebsd.org> <CAOtMX2jSonHQ9xzVD3Q9XS2twBm_CT3Tquwn%2Bf6zmc7aV0QerQ@mail.gmail.com> <20180105221330.GD95035@spindle.one-eyed-alien.net>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WaX0PKN5PUEovsUibQhwjaF1BhrNSms3T Content-Type: multipart/mixed; boundary="9s0LvRWHs38dRhcArdcFTcnu7qtmMJMoq"; protected-headers="v1" From: Eugene Grosbein <eugen@grosbein.net> To: Brooks Davis <brooks@freebsd.org>, Alan Somers <asomers@freebsd.org> Cc: Yuri <yuri@rawbw.com>, Ian Lepore <ian@freebsd.org>, Freebsd hackers list <freebsd-hackers@freebsd.org> 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> <CAOtMX2jSonHQ9xzVD3Q9XS2twBm_CT3Tquwn+f6zmc7aV0QerQ@mail.gmail.com> <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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5A4FF989.1040709>