943,735 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1092
  • C RSS
Nov 10th, 2008
0

Pipe in Unix

Expand Post »
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???
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
hajjo is offline Offline
101 posts
since Mar 2008
Nov 10th, 2008
0

Re: Pipe in Unix

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?
Reputation Points: 10
Solved Threads: 6
Newbie Poster
bionicseraph is offline Offline
19 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Error while running make of mod_wsgi
Next Thread in C Forum Timeline: warning: assignment makes pointer from integer without a cast





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC