-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipex.c
More file actions
41 lines (37 loc) · 1.56 KB
/
pipex.c
File metadata and controls
41 lines (37 loc) · 1.56 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: sanmetol <sanmetol@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/11 16:47:53 by sanmetol #+# #+# */
/* Updated: 2024/11/26 22:27:54 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
int main(int argc, char **argv, char **envp)
{
t_pipex pipex;
int i;
if (argc < 5 || (argc < 6 && !ft_strncmp(argv[1], "here_doc", 8)))
handle_error('f', ERROR_MS, EXIT_FAILURE);
init_pipex(&pipex, argc, argv, envp);
create_pipes(&pipex);
fork_and_exec(&pipex, argv, envp);
close_pipes(&pipex);
i = 0;
while (i < pipex.cmd_count)
{
wait(NULL);
i++;
}
cleanup(&pipex);
return (0);
}
//DEBUGGER: fprintf(stderr, "Mensaje de depuración\n");
// ./pipex infile "grep a1" "wc -w" outfile
// ./pipex infile "grep a1 -v" "sort" "uniq" "wc -w" outfile
// ./pipex here\_doc END "grep a" "wc -l" outfile
// grep a << END | wc -l >> outfile
// valgrind --leak-check=full