The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-08-2005
steveneliuk steveneliuk is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 6
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/
  #2 (permalink)  
Old 02-09-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,723
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.
  #3 (permalink)  
Old 02-09-2005
steveneliuk steveneliuk is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 6
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
  #4 (permalink)  
Old 02-09-2005
steveneliuk steveneliuk is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 6
Its blocked because of I/0

answered my own question.

Use poll() or select(), incase anyone ever searches this thread.

Steven
  #5 (permalink)  
Old 05-23-2007
~monu~ ~monu~ is offline
Registered User
  
 

Join Date: Feb 2007
Location: bangalore
Posts: 4
good link

Hi, its a very good link, thanks and if any info u know pls share with the community.
  #6 (permalink)  
Old 05-23-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
1. only one process can read a pipe at any time, multiple can write.

2. scalability, if you want more processes that allowable file descriptors per process what do you do?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0