Quote:
Originally Posted by golmschenk
If I were to make a parent who forked to having multiple children, how do I run the pipes in this kind of situation? For the particular case I'm looking at, I'd be happy with all the children receiving the same information from the parent at all times. For this am I able to do something similar to the example here:
http://tldp.org/LDP/lpg/node11.html
Except fork more then once? So that in the end it would be as if it's just one pipe but it leads to two children? So that anything sent through the pipe would be received by both of them? If not, how could I go about setting up such a situation? Thanks for your time!
|
You might consider using named pipes:
man 3 mkfifo
.
Still the parent (i.e. source of info, the broadcaster) will have to write into each named pipe separately, i.e. the children won't receive info simultaneously. Anyway, with a single CPU/core they physically can't receive info simultaneously - only one child (if any) is in fact executed at any given moment of time.
You can achieve better synchronization by writing one word (the word being the atom you want to send, e.g. an FP number) at a time into each named pipe - rather than the whole buffer of words.
You'll need to start the children first, to be more exact, the children (listeners) should start listening before the broadcaster starts writing into named pipes.