![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AIX 5.3 - There is no process to read data written to a pipe | vigsgb | UNIX for Advanced & Expert Users | 6 | 05-22-2009 04:59 AM |
| Wall, Write, select users, pipe a text file, HELP Before I'm Bald! | chimodel | UNIX Desktop for Dummies Questions & Answers | 1 | 03-13-2008 05:50 PM |
| Problem in read() from a pipe | JDS | High Level Programming | 2 | 10-13-2006 10:19 AM |
| read after pipe problem OSX10.4 | relyveld | Shell Programming and Scripting | 5 | 07-07-2005 08:56 PM |
| read, write & STDOUT_FILENO.... | M3xican | High Level Programming | 2 | 07-17-2002 04:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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/ |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|