Unix IPC Question:
Download Questions PDF

How to write the program on full-duplex communication on bidirectional(e.g using two pipes)?

Answer:

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/ipc.h>
#include<sys/types.h>
int main()
{
int p1[2],p2[2],i;
char buf[5];
pipe(p1);
pipe(p2);
if(fork()==0)
{
printf("\n this is child(the input text is text)\n");
close(p1[0]);
close(p2[1]);
write(p1[1],"text",5);
read(p2[0],buf,5);
write(1,buf,5);
}
else
{
printf("\n this is parent(the output text is text)\n");
close(p2[0]);
close(p1[1]);
read(p1[0],buf,5)
for(i=0;i<4;i++)
buf[i]=to upper(buf[i]);
write(p2[1],buf,5)
}
}

Download Unix Inter-Process Communication (IPC) Interview Questions And Answers PDF

Previous QuestionNext Question
What is semaphone?What are the system calls used for process management: