From owner-freebsd-bugs Tue Sep 10 9:30: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 787FB37B400 for ; Tue, 10 Sep 2002 09:30:04 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FF6043E42 for ; Tue, 10 Sep 2002 09:30:04 -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 g8AGU3JU091106 for ; Tue, 10 Sep 2002 09:30:03 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g8AGU36d091105; Tue, 10 Sep 2002 09:30:03 -0700 (PDT) Date: Tue, 10 Sep 2002 09:30:03 -0700 (PDT) Message-Id: <200209101630.g8AGU36d091105@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: alo@louko.com (Antti Louko) Subject: Re: misc/41331: Pthread library open sets O_NONBLOCK flag and causes unnecessary EAGAIN errors especially with /dev/stdout. Reply-To: alo@louko.com (Antti Louko) 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: alo@louko.com (Antti Louko) To: archie@packetdesign.com 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: 10 Sep 2002 16:26:31 -0000 Sender: archie@dellroad.org Date: Tue, 10 Sep 2002 08:26:40 -0700 From: Archie Cobbs Organization: Packet Design X-Accept-Language: en CC: freebsd-gnats-submit@FreeBSD.org, deischen@freebsd.org 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 But the O_NONBLOCK is not set in the kernel. It is probably set in /usr/src/lib/libc_r/uthread/uthread_fd.c (which sets O_NONBLOCK flags for fds in range 0..2) or somewhere else in libc_r because it doesn't happen without thread library. But someone who is familiar with the pthreads library should check what should happen. I don't feel competent to fix this. Regards, Antti To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message