From owner-freebsd-bugs Tue Sep 10 8:40:14 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4CD4537B400 for ; Tue, 10 Sep 2002 08:40:07 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D90CA43E72 for ; Tue, 10 Sep 2002 08:40:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g8AFe6JU081225 for ; Tue, 10 Sep 2002 08:40:06 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g8AFe6el081224; Tue, 10 Sep 2002 08:40:06 -0700 (PDT) Date: Tue, 10 Sep 2002 08:40:06 -0700 (PDT) Message-Id: <200209101540.g8AFe6el081224@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Archie Cobbs Subject: Re: misc/41331: Pthread library open sets O_NONBLOCK flag and causes unnecessary EAGAIN errors especially with /dev/stdout. Reply-To: Archie Cobbs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/41331; it has been noted by GNATS. From: Archie Cobbs To: Antti Louko Cc: freebsd-gnats-submit@FreeBSD.org, deischen@freebsd.org Subject: Re: misc/41331: Pthread library open sets O_NONBLOCK flag and causes unnecessary EAGAIN errors especially with /dev/stdout. Date: Tue, 10 Sep 2002 08:26:40 -0700 Antti Louko wrote: > I just tried it in 4.6 Release and 4.6.2 and it still occurs. I think this is a kernel bug, rather than a pthread bug. What's happening is that the file descriptor associated with /dev/stdout is "inheriting" the flags associated with file descriptor 0. This happens on both -stable and -current. This seems like broken behavior to me: flags should be associated with the file descriptor, not the underlying device or entity. But I don't know what the "official" semantics of /dev/stdout are supposed to be. The program below demonstrates the problem: $ cc -g -Wall -o flags flags.c $ ./flags O_NONBLOCK is set -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com #include #include #include int main(int argc, char **argv) { int flags; int fd; if ((flags = fcntl(0, F_GETFL, 0)) == -1) err(1, "fcntl"); if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) err(1, "fcntl"); if ((fd = open("/dev/stdout", O_WRONLY, 0)) == -1) err(1, "open"); if ((flags = fcntl(fd, F_GETFL, 0)) == -1) err(1, "fcntl"); printf("O_NONBLOCK is %s\n", (flags & O_NONBLOCK) ? "set" : "not set"); return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message