forked from vighneshwho/gitClass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipe2.c
More file actions
35 lines (32 loc) · 659 Bytes
/
pipe2.c
File metadata and controls
35 lines (32 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
#include <unistd.h>
void main()
{
int a[2],d[2],x;
pipe(a);
pipe(d);
char s[20],s1[20],b[20],c[20];
x=fork();
if (x>0)
{
printf("-----Parent is Writing-----\n");
printf("Enter the String:\n");
scanf("%s",s);
write(d[1],s,10);
read(a[0],b,10);
printf("------Parent is Reading-------\n");
printf("String Entered is:%s\n",b);
}
else if(x==0)
{
read(d[0],s1,10);
printf("---------Child is Reading--------\n");
printf("String Entered is:%s\n",s1);
printf("----------Child is Writing-------\n");
printf("Enter the String:\n");
scanf("%s",c);
write(a[1],c,10);
}
else
printf("Error Message:");
}