Pipe in Unix

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 60
Reputation: hajjo is an unknown quantity at this point 
Solved Threads: 0
hajjo hajjo is offline Offline
Junior Poster in Training

Pipe in Unix

 
0
  #1
Nov 10th, 2008
I am doing fork(), I need to send messages between parent & child..

am using this..


char readbuffer[80];
int fd[2], nbytes;


if(child == 0)
{
close(fd[0]);
nbytes = read(fd[0], readbuffer, sizeof(readbuffer);
index = atoi(readbuffer);
}



else{
close(fd[1]);
sprintf(sending, "%i", index);
write(fd[1], sending, strlen(sending)+1);
}





Index is an integer am sending to the child...its not working.anyone know why???
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 19
Reputation: bionicseraph is an unknown quantity at this point 
Solved Threads: 6
bionicseraph bionicseraph is offline Offline
Newbie Poster

Re: Pipe in Unix

 
0
  #2
Nov 10th, 2008
Are you using the fd array to communicate between the two? If so (and I don't see how it works) you are writing using fd[1] and reading using fd[0], could that be it?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC