-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
executable file
·34 lines (32 loc) · 1.38 KB
/
main.c
File metadata and controls
executable file
·34 lines (32 loc) · 1.38 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgallo-p <dgallo-p@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/25 13:06:58 by dgallo-p #+# #+# */
/* Updated: 2022/02/23 13:14:21 by dgallo-p ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/pipex.h"
int main(int argc, char **argv, char *envp[])
{
get_path(envp);
treat_argvs(argc, argv);
pipe(my_pipex.fd);
my_pipex.pid1 = fork();
if (my_pipex.pid1 == 0)
first_child(argv, envp);
my_pipex.pid2 = fork();
if (my_pipex.pid2 == 0)
second_child(argv, envp);
close(my_pipex.fd[0]);
close(my_pipex.fd[1]);
waitpid(my_pipex.pid1, &my_pipex.status, 0);
check_pid(my_pipex.status);
waitpid(my_pipex.pid2, &my_pipex.status, 0);
check_pid(my_pipex.status);
free_struct();
return (0);
}