Subject: Re: dlopen() on a fifo
To: Jed Davis <jdev@panix.com>
From: Kirk Russell <kirk@ba23.org>
List: tech-misc
Date: 05/14/2006 20:05:15
On Fri, 12 May 2006, Jed Davis wrote:

> tron@zhadum.org.uk (Matthias Scheler) writes:
>
> > 	Kirk Russell <kirk@ba23.org> writes:
> >> I am using NetBSD 3.0.  I found that dlopen() will block if the given
> >> path is a fifo:
> >>
> >> 	$ mkfifo -m a+wrx afifo
> >> 	$ ksh -c "LD_PRELOAD=./afifo /usr/bin/true"
> >> 	[... blocked ...]
> >>
> >> Is this expected behaviour?
> >
> > Yes. Processes get blocked if they try to read from a FIFO and there is
> > no writer.
>
> More to the point, the *open* will block if there's nothing on the
> other end (and O_NONBLOCK hasn't been given).

But since fifos don't appear to support mmap() or seek, I would
guess that dlopen() of a fifo cannot work even when the caller is
unblocked by a writer.  You have bad news for caller -- why not give
it sooner than later.  It appears that opendir() does an open()
O_NONBLOCK and a fstat to ensure the call doesn't block on a fifo.
I guess I expected dlopen() to be in the same class as opendir() and
not the regular open() class.

Just curious.  Thanks for the feedback :-)

-- 
Kirk Russell            <kirk@ba23.org>            http://www.ba23.org/
Bridlewood Software Testers Guild                  Ottawa Ontario Canada