-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipe.c
35 lines (31 loc) · 731 Bytes
/
pipe.c
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 "header.h"
QUE *q;
int size;
void pipecmd(char *p)
{
int pip[2],i,j;
char *s[20];
seperator(s,p,'|');
if(fork()==0)
{
pipe(pip);
if(fork()==0)
{
close(1);
dup(pip[1]);
close(pip[0]);
command(s[0]);
exit(0);
}
else
{
close(0);
dup(pip[0]);
close(pip[1]);
command(s[1]);
}
wait(0);
exit(0);
}
wait(0);
}