The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: pipe read and write with many forked children
cldnails
Newbie
Rank: 1



UID 91
Digest Posts 0
Credits 0
Posts 44
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:44 AM  Profile | P.M. 
pipe read and write with many forked children



pipe read and write with many forked children



i know how to read and write if i have a forked process with only one child. however what is involved with reading and writing with many forked processes. say one parent that forks 5 children, and needs to communicate with all 5 in half duplex.


int temp[2], counter=0;

do{
pipe(temp);

if(fork()>0){
//store values of temp in a 2 dimensional array then re-index the array @ counter.
}
counter++
}while(counter<5);


then if i access each the 2 dimensional array at location array[0][1] i cold write to child 1, and read child 1 at array[0][0];

is there an easier way?

im gong to implement this shortly, please let me know if im on the right track.

thanks for your time,


Top
kapengbarako
Newbie
Rank: 1



UID 212
Digest Posts 0
Credits 0
Posts 44
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:44 AM  Profile | P.M. 
probably a better choice: shared memory and a semaphore

there is a nice free online book about advanced programming that might help you -

http://www.advancedlinuxprogramming.com/alp-folder

try chapter 5 on 'interprocess communication' - there are examples.
Top
 

 

All times are GMT, the time now is Mar 22, 2010 01:57 PM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005724 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP