-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipex.c
More file actions
41 lines (38 loc) · 1.54 KB
/
Copy pathpipex.c
File metadata and controls
41 lines (38 loc) · 1.54 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
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jbuan <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/27 10:29:53 by jbuan #+# #+# */
/* Updated: 2021/09/27 10:30:10 by jbuan ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
int pipex(int argc, char *argv[])
{
struct s_list s;
malloc_files(argc, argv, &s.stock1, &s.stock2);
copy_file1_to_stock1(argc, argv, s.stock1);
copy_file2_to_stock2(argc, argv, s.stock2);
ft_exit(s.stock1);
pipe(s.fd2);
s.id = fork();
if (s.id == 0 && s.stock1)
{
malloc_tab(2, argv, &s.stock);
malloc_strings(2, argv, s.stock);
copies(2, argv, s.stock);
child_process(s.stock1, s.stock, s.fd2);
}
else if (s.id != 0 && s.stock2)
{
malloc_tab(3, argv, &s.stock);
malloc_strings(3, argv, s.stock);
copies(3, argv, s.stock);
parent_process(s.stock2, s.stock, s.fd2);
}
free_everything(s.stock1, s.stock2, s.stock);
return (0);
}