Beispiel #1
0
void	ft_pipe(t_line *tree, char ***env, int fd[2])
{
	pid_t	father;
	pid_t	father2;

	father = fork();
	if (!father)
	{
		ft_dup(fd, 0, 1);
		ft_sh2(tree->left, env);
		exit(0);
	}
	father2 = fork();
	if (!father2)
	{
		ft_dup(fd, 1, 0);
		ft_sh2(tree->right, env);
		exit(0);
	}
	if (father || father2)
	{
		close(fd[0]);
		close(fd[1]);
		waitpid(father, NULL, 0);
		waitpid(father2, NULL, 0);
	}
}
t_cmds	*make_my_line_cmd(t_char *l_char, t_cmds *l_cmds)
{
	t_char	*tmp;
	char	*line;
	int		i;
	int		j;

	i = 0;
	tmp = l_char;
	while (tmp->befor != NULL)
		tmp = tmp->befor;
	j = ft_count_liste(tmp);
	line = (char *)malloc(sizeof(char) * (j + 1));
	while (tmp != NULL)
	{
		line[i] = tmp->c;
		tmp = tmp->after;
		i++;
	}
	line[i] = '\0';
	l_cmds = make_my_lc_cmds(line, l_cmds);
	if (ft_strcmp(l_cmds->str, "exit") != 0)
		ft_sh2(l_cmds->str);
	ft_clear_liste_cmds(l_cmds);
	ft_my_sig_cmp_file(-2);
	save_history_sig(l_cmds, 1);
	return (l_cmds);
}
Beispiel #3
0
void	ft_left(t_line *tree, char ***env)
{
	pid_t	father;

	father = fork();
	if (!father)
	{
		if (ft_start_left(tree) == -1)
			exit(0);
		ft_sh2(tree->left, env);
		exit(0);
	}
	else
		wait(NULL);
}