Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jan 2018 10:05:42 -0800 (PST)
From:      Don Lewis <truckman@FreeBSD.org>
To:        Eugene Grosbein <eugen@grosbein.net>
Cc:        Eric van Gyzen <eric@vangyzen.net>, Brooks Davis <brooks@freebsd.org>, Alan Somers <asomers@freebsd.org>, 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:  <tkrat.f9f3a7ffe393636e@FreeBSD.org>
In-Reply-To: <5A5399AA.9020309@grosbein.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> <5A4FF989.1040709@grosbein.net> <7b977409-96ee-5acb-60d0-3b0e124495f0@vangyzen.net> <5A5002D9.9080205@grosbein.net> <d75e9334-4da1-125c-73a5-1115003d12b5@vangyzen.net> <5A5399AA.9020309@grosbein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On  8 Jan, Eugene Grosbein wrote:
> 08.01.2018 23:13, Eric van Gyzen wrote:
> 
>> Right, which is the reason such bugs are hard to diagnose.  Optionally
>> killing the process on close->EBADF would help find buggy code when
>> another thread did NOT re-open the file descriptor between the two close
>> calls.
> 
> Wouldn't "close(f); assert(errno != EBADF);" be better?

That can produce false positives.  The close() might be successful,
in which case it will not touch errno, and errno might have been set
to EBADF by some earlier operation.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?tkrat.f9f3a7ffe393636e>