tests de pipes et fork et execve et wait

This commit is contained in:
hugogogo
2021-10-17 22:12:55 +02:00
parent 98f247a378
commit 226829b891
4 changed files with 94 additions and 25 deletions

View File

@@ -17,20 +17,37 @@ void print_tab(char **array)
i = 0;
while (array[i])
{
printf("%i: %s\n", i, array[i]);
printf("%i: [%s]\n", i, array[i]);
i++;
}
}
void pipes_hugo(char *input)
void execute_cmd(char *cmd, t_all *c)
{
const char *filename;
char **argv;
char **envp;
// (void)cmd;
filename = ft_strtrim(cmd, " ");
printf("[%s]\n", filename);
// filename = "/bin/ls";
argv = ft_split(filename, ' ');
envp = c->envp;
execve(filename, argv, envp);
}
void pipes_hugo(char *input, t_all *c)
{
char **split;
int nbr_pipes;
int i;
split = ft_split(input, '|');
split[0] += 5; // pour sauter la premiere entree qui est "pipe"
nbr_pipes = size_tab(split);
//printf("%i\n", nbr_pipes);
//print_tab(split);
i = 0;
execute_cmd(split[i], c);
}