close() failing with ECONNRESET

Timo Sirainen tss at iki.fi
Tue Jun 8 13:13:51 UTC 2010


I see that since FreeBSD 6.3 close() can fail with:

> [ECONNRESET]	The underlying object was a stream socket that was
> 		shut down by the peer before all pending data was
> 		delivered.

Could someone explain what this is useful for? I'm not aware of any
other OS that does this. Is this really something that many programs
care about? I'd think there are only very few, and those exceptions
could use some other syscall before close() to find out about it.
Instead now you're forcing everyone else to change their code from:

if (close(fd) < 0) log(..);

to 

if (close(fd) < 0 && errno != ECONNRESET) log(..);

or to write some wrapper to close().



More information about the freebsd-hackers mailing list