![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wall, Write, select users, pipe a text file, HELP Before I'm Bald! | chimodel | UNIX Desktop for Dummies Questions & Answers | 1 | 03-13-2008 01:50 PM |
| Problem in read() from a pipe | JDS | High Level Programming | 2 | 10-13-2006 07:19 AM |
| AIX 5.3 - There is no process to read data written to a pipe | vigsgb | UNIX for Advanced & Expert Users | 4 | 06-21-2006 01:09 AM |
| read after pipe problem OSX10.4 | relyveld | Shell Programming and Scripting | 5 | 07-07-2005 05:56 PM |
| read, write & STDOUT_FILENO.... | M3xican | High Level Programming | 2 | 07-17-2002 01:41 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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, New to unix and c/ |
| Forum Sponsor | ||
|
|
|
|||
|
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. |
|
|||
|
Hey thanks that was a great link, lots of good info for the future.
But anyway, im using pipe and my initial idea is working great except one flaw. The parent process will sit on a read until there is available data. How to get him to go on if there is not data, not keep waiting? Thanks for any help, Steven |