Is it considered to be ok to not check the return code of close(2) in base?

Eugene Grosbein eugen at grosbein.net
Fri Jan 5 22:18:15 UTC 2018


06.01.2018 5:13, Brooks Davis wrote:

>> I would argue the opposite.  There are very few reasons why close(s) would
>> ever fail, and the most likely is EBADF.  EBADF indicates a programming
>> bug, like a double close or use of an uninitialized variable.  Those could
>> 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.
> 
> 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 != -1
> where EBADF would be returned.

A medicine should not be worse worse than the disease, imho.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20180106/68a39a5a/attachment.sig>


More information about the freebsd-hackers mailing list