From owner-freebsd-doc@FreeBSD.ORG Fri Oct 10 19:27:17 2014 Return-Path: Delivered-To: freebsd-doc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07788934 for ; Fri, 10 Oct 2014 19:27:17 +0000 (UTC) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id C08B77F8 for ; Fri, 10 Oct 2014 19:27:16 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 9FBE2359D70; Fri, 10 Oct 2014 21:27:13 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 9001528494; Fri, 10 Oct 2014 21:27:13 +0200 (CEST) Date: Fri, 10 Oct 2014 21:27:13 +0200 From: Jilles Tjoelker To: d@delphij.net Subject: Re: accept(2): may return EAGAIN Message-ID: <20141010192713.GA85547@stack.nl> References: <5435E0C1.9000403@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5435E0C1.9000403@delphij.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-doc@freebsd.org X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2014 19:27:17 -0000 On Wed, Oct 08, 2014 at 06:11:29PM -0700, Xin Li wrote: > It seems like accept(2) may and does return EAGAIN. Do the following > change look appropriate to you? > Index: lib/libc/sys/accept.2 > =================================================================== > --- lib/libc/sys/accept.2 (revision 272709) > +++ lib/libc/sys/accept.2 (working copy) > @@ -28,7 +28,7 @@ > .\" @(#)accept.2 8.2 (Berkeley) 12/11/93 > .\" $FreeBSD$ > .\" > -.Dd October 1, 2013 > +.Dd October 9, 2014 > .Dt ACCEPT 2 > .Os > .Sh NAME > @@ -201,7 +201,7 @@ The > .Fa addr > argument is not in a writable part of the > user address space. > -.It Bq Er EWOULDBLOCK > +.It Bo Er EWOULDBLOCK Bc or Bq Er EAGAIN > The socket is marked non-blocking and no connections > are present to be accepted. > .It Bq Er ECONNABORTED This is correct, but it is inconsistent to write "[EWOULDBLOCK] or [EAGAIN]" only in one particular man page. The situation in FreeBSD is that EWOULDBLOCK == EAGAIN. This is permitted but not required by POSIX. The two errors may have different numeric values and in the case of socket operations, EWOULDBLOCK may be returned instead of EAGAIN. (For example, accept(2) may return [EWOULDBLOCK] instead of [EAGAIN], and read(2) may return [EWOULDBLOCK] instead of [EAGAIN] if the operation is on a socket.) Unfortunately, intro(2) does not mention EWOULDBLOCK at all. BSD flock(2) and the related open(2) flags also use EWOULDBLOCK; these can probably stay that way (applications need not check for [EAGAIN]). -- Jilles Tjoelker