Date: Tue, 27 Feb 2001 15:15:33 +0000 (GMT) From: "E.B. Dreger" <eddy+public+spam@noc.everquick.net> To: freebsd-hackers@FreeBSD.ORG Subject: Re: Where can I find out rules on blocking in threads? Message-ID: <Pine.LNX.4.20.0102271457560.15675-100000@www.everquick.net> In-Reply-To: <200102270121.RAA39980@akira.lanfear.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.20.0102271457560.15675-100000>
