-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipex.c
40 lines (37 loc) · 1.33 KB
/
pipex.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
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yichoi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 18:15:40 by yichoi #+# #+# */
/* Updated: 2022/06/13 22:42:13 by yichoi ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
int main(int argc, char *argv[], char **envp)
{
int fd[2];
pid_t pid;
pid_t pid2;
if (argc != 5)
ft_error(BAG);
if (pipe(fd) == -1)
ft_error(ERR);
pid = fork();
if (pid == -1)
ft_error(ERR);
else if (pid == 0)
cmd1_process(fd, argv, envp);
pid2 = fork();
if (pid2 == -1)
ft_error(ERR);
else if (pid2 == 0)
cmd2_process(fd, argv, envp);
close(fd[0]);
close(fd[1]);
waitpid(-1, 0, 0);
waitpid(-1, 0, 0);
return (0);
}