-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_pipe.c
More file actions
37 lines (34 loc) · 825 Bytes
/
do_pipe.c
File metadata and controls
37 lines (34 loc) · 825 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
36
37
#include "headers.h"
void do_pipe(int rdhere, int wrthere ,int nocmd, char **cmds)
{
// printf("hereiam %d ",nocmd);
int i = 0;
int fildes[2];
for(i = 0;i< nocmd;i++)
{
if(i == nocmd-1)
{
char temp[1000];
strcpy(temp,cmds[i]);
if (pipe(fildes) < 0)
{
perror("Could not create pipe.");
exit(1);
}
inputgiven(rdhere,1,temp);
}
else
{
char temp[1000];
strcpy(temp,cmds[i]);
if (pipe(fildes) < 0)
{
perror("Could not create pipe.");
exit(1);
}
inputgiven(rdhere,fildes[1],temp);
close(fildes[1]);
rdhere=fildes[0];
}
}
}