hi all!
I'm writing a C++ program where I have a parent and a child process which communicate with a bidirectional pipe.The parent process creates the pipe and WRITES a string to it.Then the child process READS the string the parent sent and WRITES data to the pipe,which after the parent READS.
It's the first time I have to deal with a bidirectional pipe and I'm not sure how to do it.
Here's what I have tried so far
Code:
//parent
int r = mkfifo (pipeName, 0666);
if (r < 0) {
perror("Error creating in creation");
exit (1);
}
//parent opens pipe for reading and writing
int fd = open(pipeName,O RDWR);
dup2(1,fd);
//everything parent writes go to fd
int pid=fork();
if(pid==0){
//child process
//exec child and send to it the name of the pipe
}
I'm sure is wrong but I have only used one-way pipes so far so it's difficult to understand how bidirectional pipes do work..
Any help would be very appreciated!
Thank you