Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Name: Kanchan Kundan Chaudhari Date:-

Roll No. : 01

Subject: - Advance Unix Programming Sub. Teacher: Ashfaque Shaikh

/* Program for Inter Process Communication using pipe */


#include<stdio.h>
#include<unistd.h>
int main()
{
int n,fd[2];
pid_t pid;
char line[20];
if(pipe(fd)<0)
printf("\n error in pipe");
if((pid=fork())<0)
printf("\n error in fork");
else if(pid>0)
{
write(fd[1]," HelloWorld\n",12);
}
else
{
n=read(fd[0],line,12);
printf("%s",line);
}
return 0;
}

Output:
linux5@linux5-System-Product-Name:~/Desktop$ cc pipe.c
linux5@linux5-System-Product-Name:~/Desktop$ ./a.out
HelloWorld

You might also like