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???

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.