From owner-freebsd-hackers Tue Feb 27 12:51:20 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from akira.lanfear.com (akira.lanfear.com [208.12.11.174]) by hub.freebsd.org (Postfix) with ESMTP id 4212D37B719 for ; Tue, 27 Feb 2001 12:51:17 -0800 (PST) (envelope-from mwlist@lanfear.com) Received: from sapporo.lanfear.com (h-64-105-36-216.snvacaid.covad.net [64.105.36.216]) by akira.lanfear.com (8.9.3/8.9.3) with SMTP id MAA42206; Tue, 27 Feb 2001 12:51:11 -0800 (PST) (envelope-from mwlist@lanfear.com) Date: Tue, 27 Feb 2001 12:51:11 -0800 (PST) From: Marc W Message-Id: <200102272051.MAA42206@akira.lanfear.com> To: Peter Dufault , Marc W Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Where can I find out rules on blocking in threads? MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Mailer: Kiltdown 0.7 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > I think the FreeBSD behavior is wrong, the spec says that when > opening a FIFO with O_NONBLOCK clear that: > > > An open() for reading-only shall block the calling thread until a > > thread opens the file for writing. An open() for writing-only > > shall block the calling thread until a thread opens the file for > > reading. > > The FBSD man pages will let you know if something will block or > not, for example, look at the "implementation notes" section for > open. > You can open the fifo non-blocking and then clear O_NONBLOCK using > fcntl, hopefully that will work in all environments. I have tried this, but it gets even weirder then: - the call to open always succeeds right away (even when there are no threads on the write end of the fifo) - the immediately following call to read() also succeeds, returning 0 bytes as the number of bytes read. it gets worse -- when i change my loop to be: while (1) { fifo = open(fifoPath, O_RDONLY | O_NONBLOCK); cread = read(fifo, buf, sizeof(buf)); if (cread > 0) do_something(); close(fifo); usleep(100000); } anybody who tries to open the write end of the fifo ends up hanging .. argh! i'll keep investigating... my poor "2 hour solution to single instancing" is going into day 3 :-) marc. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message