[Gllug] pipes and C++

Bruce Richardson itsbruce at workshy.org
Sun Sep 12 23:17:44 UTC 2010


On Mon, Sep 13, 2010 at 12:54:46AM +0200, salsaman at xs4all.nl wrote:
> 
> I think you could do it with fifos, e.g.
> 
> mkfifo fifo1
> mkfifo fifo2
> 
> A > fifo1
> B > fifo2 < fifo1
> C < fifo2
> 

You're part of a way there, in that the fifos will survive the closure
of A's STDIN, but you're missing a big part of the solution, because he
wants the output to be repeated at regular intervals.  With this method,
A, at the very least, should not be using redirection but should take
the fifo as a parameter, as in

  A -r 3 -f fifo1

This would allow A to repeatedly close and open fifo1.  B *could* be
left as it is and just be run in a loop, as in 

  while true; do
    B > fifo2 < fifo1
  done

One problem with that is that you can't rely on B to be sending its
output every 3 seconds, just because A is doing so.  If that three
second interval is important at each stage (although I'm a little
puzzled as to why it should matter anywhere but at the final stage),
then it also needs to be rewritten so that it can run as

  B -r 3 -f1 fifo1 -f2 fifo2

-- 
Bruce

If the universe were simple enough to be understood, we would be too
simple to understand it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 204 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20100913/6671faab/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list