A trick with perl

Andrew Pimlott andrew at pimlott.net
Mon Jan 5 00:47:58 CET 2004


On Sun, Jan 04, 2004 at 02:46:14PM -0800, Chris Fortune wrote:
> "Andrew Pimlott" <andrew at pimlott.net> wrote:
> > That's great, but I'm fairly sure it is not possible with the code
> > you posted.  One, you created the "fifo" with "mknod $file b", which
> > is not correct.
> 
> Yes, true, 'system("mknod filename.txt b");' produces a usage error, but
> works anyways!

I see what is happening now.  "mknod filename.txt b" does not work,
and as a result your open call creates a regular file.  So you are
really feeding your filters a regular file.  This explains why you
did not run into the problem I described.

I suggest you examine what is happening in your program more
closely.  You will find that your understanding was deeply flawed,
but you will learn a lot in the process.

Also, as another poster noted, a temporary file is more expensive
than a pipe.  However, it has the merit that you can reuse it for
each filter.  So I would be inclined to go with this approach--just
clarify the code so it looks like it's doing what it's actually
doing!

> Using mknod with the 'b' option creates a "block special
> file"  Such devices can be read a "block" (many characters) at a time, thus
> buffering data in main memory until a reader is attached.  You are supposed
> to give two numbers as command-line options, the "major and minor device
> numbers", but without them, it defaults to main memory, which is where we
> want it to reside anyways.

This isn't accurate at all.  More quality time with your manuals is
prescribed.  :-)

Andrew




More information about the Bogofilter mailing list