Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Feb 2001 16:02:28 -0500 (EST)
From:      Peter Dufault <dufault@hda.hda.com>
To:        Marc W <mwlist@lanfear.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Where can I find out rules on blocking in threads?
Message-ID:  <200102272102.f1RL2Sr24485@hda.hda.com>
In-Reply-To: <200102272051.MAA42206@akira.lanfear.com> from Marc W at "Feb 27, 2001 12:51:11 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
>     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

Set the FIFO blocking with fcntl(2) after you open it.  I'll hack up my test
program to be sure that works.

Peter

--
Peter Dufault (dufault@hda.com)   Realtime development, Machine control,
HD Associates, Inc.               Fail-Safe systems, Agency approval

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?200102272102.f1RL2Sr24485>