From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 13 21:20:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 285AFB56 for ; Sun, 13 Apr 2014 21:20:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 154011698 for ; Sun, 13 Apr 2014 21:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3DLK0pj022575 for ; Sun, 13 Apr 2014 21:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3DLK0d8022574; Sun, 13 Apr 2014 21:20:00 GMT (envelope-from gnats) Date: Sun, 13 Apr 2014 21:20:00 GMT Message-Id: <201404132120.s3DLK0d8022574@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jilles Tjoelker Subject: Re: kern/159179: [libc] close(2) emitting ECONNRESET is not POSIX compliant X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Apr 2014 21:20:01 -0000 The following reply was made to PR kern/159179; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, freebsd@grem.de Cc: Subject: Re: kern/159179: [libc] close(2) emitting ECONNRESET is not POSIX compliant Date: Sun, 13 Apr 2014 23:14:27 +0200 In FreeBSD PR kern/159179, you wrote: > With the advent of FreeBSD 6.3 the close(2) call was changed to return > errno ECONNRESET under certain circumstances. The man page was changed > accordingly, but in my understanding errno = ECONNRESET is not covered > by POSIX.1-2008 (see > http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html). > Also all other implementations of close I've seen in the past do not > behave like this, which leads to actual problems in reality. > In practice this means that all projects ported to FreeBSD would need > to get reviewed if they can handle these situations gracefully, which > usually doesn't happen. POSIX permits additional errors. XSH 2.3 Error Numbers says: ] Implementations may generate error numbers listed here under ] circumstances other than those described, if and only if all those ] error conditions can always be treated identically to the error ] conditions as described in this volume of POSIX.1-2008. ] Implementations shall not generate a different error number from one ] required by this volume of POSIX.1-2008 for an error condition ] described in this volume of POSIX.1-2008, but may generate additional ] errors unless explicitly disallowed for a particular function. The page for close() does not exclude [ECONNRESET] or any other error. One problem with close() errors is that there may be confusion about whether the file descriptor is still valid. In FreeBSD (and also Linux), close() on a valid file descriptor always deallocates it, even if there is an error while closing. The problem reported in kern/146845 may cause [ECONNRESET] errors even when no data was lost. This may have been fixed. -- Jilles Tjoelker