From owner-freebsd-standards@FreeBSD.ORG Fri Apr 11 12:44:31 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 899D837B401 for ; Fri, 11 Apr 2003 12:44:31 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id C111B43F93 for ; Fri, 11 Apr 2003 12:44:30 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h3BJiTA7029969 for ; Fri, 11 Apr 2003 13:44:29 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 11 Apr 2003 13:44:16 -0600 (MDT) Message-Id: <20030411.134416.71552075.imp@bsdimp.com> To: standards@freebsd.org From: "M. Warner Losh" X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Non-compliant FreeBSD behavior? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Apr 2003 19:44:31 -0000 A number of places I've seen says that the BUGGY section should be identical to the else part. That is, setting O_NONBLOCK via fcntl should result in the same behavior as setting it using FIONBIO. However, I've observed that for both threaded and unthreaded programs the BUGGY part doesn't work, while the other part does. Is there something subtle I'm missing? What do the standards have to say about this? Warner #include #include #include #include #include #include #include #include int main(void) { int fd; struct in_addr addr; struct sockaddr_in sa; int flags; fd = socket(PF_INET, SOCK_STREAM, 0); inet_aton("1.2.3.4", &addr); sa.sin_len = sizeof(sa); sa.sin_family = AF_INET; sa.sin_port = htons(1234); memcpy(&sa.sin_addr, &addr, sizeof(addr)); #if BUGGY flags = fcntl(fd, F_GETFL, NULL); flags |= O_NONBLOCK; if (fcntl(fd, F_SETFL, &flags) == -1) err(1, "fcntl"); #else flags = 1; if (ioctl(fd, FIONBIO, &flags)) err(1, "ioctl"); #endif if (connect(fd, (struct sockaddr *) &sa, sizeof(sa))) err(1, "connect"); exit(0); }