From owner-freebsd-hackers Tue Feb 27 7:15:40 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from a.mx.everquick.net (a.mx.everquick.net [216.89.137.3]) by hub.freebsd.org (Postfix) with ESMTP id 30D0037B71A for ; Tue, 27 Feb 2001 07:15:35 -0800 (PST) (envelope-from eddy+public+spam@noc.everquick.net) Received: from localhost (eddy@localhost) by a.mx.everquick.net (8.9.0/8.8.7) with ESMTP id PAA16252 for ; Tue, 27 Feb 2001 15:15:33 GMT X-EverQuick-No-Abuse: Report any e-mail abuse to Date: Tue, 27 Feb 2001 15:15:33 +0000 (GMT) From: "E.B. Dreger" To: freebsd-hackers@FreeBSD.ORG Subject: Re: Where can I find out rules on blocking in threads? In-Reply-To: <200102270121.RAA39980@akira.lanfear.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Is this a library issue in libc_r? I just wrote a quick test program using rfork(RFMEM|RFPROC) to create a child thread. I then had both the parent and the child attempt to open the pre-existing file /tmp/blah with O_EXLOCK set. When I specify O_NONBLOCK, the child open() fails immediately. When I do not specify O_NONBLOCK, the child blocks indefinitely: #if TRY_NONBLOCKING # define O_XXXX (O_NONBLOCK) #else # define O_XXXX (0) #endif int main(int argc, char* *argv) { thread_creation_using_rfork(RFPROC|RFTHREAD) ; /* parent continues here */ printf("main: %d\n", open("/tmp/blah", O_RDWR|O_EXLOCK|O_XXXX)) ; for( ; ; ) ; } void childthreadproc(void *) { /* child begins here */ /* fails for O_NONBLOCK, otherwise blocks indefinitely */ printf("child: %d\n", open("/tmp/blah", O_RDWR|O_EXLOCK|O_XXXX)) ; for( ; ; ) ; } Note that I've omitted the guts of rfork(). Therefore, it seems to me that the blocking is at the library level, not the kernel level. Have I missed something? Eddy --------------------------------------------------------------------------- Brotsman & Dreger, Inc. EverQuick Internet / EternalCommerce Division E-Mail: eddy@everquick.net Phone: (316) 794-8922 --------------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message