close(2) return value handling

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

close(2) return value handling

Matthias
Hi.

Just curious why you never check the return value of the close(2) system
call for errors.

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: close(2) return value handling

Theo de Raadt-2
Matthias <[hidden email]> wrote:

> Just curious why you never check the return value of the close(2) system
> call for errors.

It never fails in a way that matters.

The program must be properly written for the fd to be alive, so EBADF
doesn't occur.

EINTR doesn't occur, and if it did, nowhere is it cleanly specified
what you do, do you call it again?  Not clear.

And if it were to fail with EIO, there is nothing you can do.  If
that happens, your underlying IO subsyste is so screwed up your dmesg
is probably starting to spew error messages.

Basically it is pointless.