[plug] Named pipe. Solution to programming problem?

Timothy White weirdo at tigris.org
Fri Nov 19 16:25:27 WST 2004


James Devenish wrote:
> In message <apb072xgvq.ln2 at shameless.plug.org.au>
> on Fri, Nov 19, 2004 at 01:09:29PM +0800, Mike Holland wrote:
> 
>>James Devenish wrote:
>>
>>>>isn't that what a named pipe does?
>>>
>>>Not in a way that satisfies all the requirements I infer from Tim.
>>>But maybe his requirements are simpler than I imagined.
>>
>>I don't get it. Whats wrong with a named pipe here?
> 
> 
> If you know how to prevent race conditions, broken pipes, etc, then
> you know more than me. Tim indicated there were multiple sources
> supplying the data and,
It is only one program supplying the data.
For example I could have a program aggregate multiple RSS feeds and do 
some manualy parsing of some web pages and generate a single RSS feed 
combined from all the sources and feed it out to a pipe (although this 
isn't a good example as it would make more sense to use sockets here.)

> for the lack of contradiction, I assumed there
> are multiple readers (or, at least, there are unknown random intervals
> between read attempts). At the very least, Tim seemed to indicate that
> the readers could not be reprogrammed with a locking mechanism on top
> of which I assumed that the inability of FIFOs to cope with multiple
> readers was inherent in the design.

Multiple readers; yes. Basically I need ANY program to be able to open 
the file (read-only) and read the contents in to use for what ever 
purpose the program wants.[1]

> Hence, I did not think that named
> pipes could satisfy Tim's requirements. But I may have been mistaken
> through inexperience or past misadventure.

The main reason the below mock up won't work is I don't want to be 
running it continually using CPU time as while only one or two instances 
may not make much of a difference, when I start running 500 instances it 
will be noticeable. Especially when some of the 'pipes' getting accessed 
may never get accessed or only once ever hour, while others may get 
accessed every minute.

Thanks
Tim
[1] A little 'mock up' example of what I am trying to do (not a real 
world example, a mock up of the design.)

--- Named pipe 'server' application
$  while true; do cat /tmp/file1 /tmp/file2 > /tmp/pipe; ifconfig eth0 
 >> /tmp/pipe; sleep 5; done &
// I the > and the >> force the file to close each time so it is 
overwritten, rather than redirecting stdout into the file as then I 
would need fancy open/close file routines so that it is overwritten each 
time round

--- 'Clients'
$ cat /tmp/pipe
...
eth0      Link encap:Ethernet  HWaddr 00:A0:0C:C7:F4:16
...
$ wc -l /tmp/pipe
12 /tmp/pipe
------------------
Tim White - Use the Fox, Luke!
PGP/GPG id: 602E944D, Pub Key Serv: subkeys.pgp.net
Fingerprint: 04C2 9682 B7B2 3006 009D  A9F3 067E EDCD 602E 944D
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me 
spread!
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20041119/4b148e0f/attachment.pgp>


More information about the plug mailing list