示例#1
0
void			try_entry(char *entry)
{
	char	**av;
	char	*exec;
	pid_t	father;

	av = ft_strsplitif(entry, &is_escaped_arg);
	if (av[0])
	{
		if (!check_is_builtins(av))
		{
			lst_to_tab(&g_lst);
			if ((exec = check_is_exec(av)))
			{
				father = fork();
				g_inf->process = 1;
				if (!father)
					execve(exec, av, lst_to_tab(&g_lst));
				else
					wait(NULL);
				free(exec);
			}
		}
	}
	free_tab_ptr(&av);
}
示例#2
0
int		exec_bin(char **param, char **path, t_lst *lst)
{
	pid_t	pid;
	int		status;
	int		i;
	char	*tmp;
	char	**env;

	i = 0;
	env = lst_to_tab(lst->next);
	while (path && path[i])
	{
		tmp = ft_strjoin(path[i], "/");
		tmp = ft_strjoin(tmp, param[0]);
		if (access(tmp, X_OK) == 0)
		{
			pid = fork();
			if (pid > 0)
				waitpid(pid, &status, 0);
			if (pid == 0)
				execve(tmp, param, env);
			return (1);
		}
		i++;
	}
	ft_putendl("shell : command not found");
	return (0);
}
示例#3
0
int		basic_exec(char **param, t_lst *lst)
{
	pid_t	pid;
	int		status;
	int		i;
	char	**env;

	i = 0;
	env = lst_to_tab(lst->next);
	if (is_exec(param) == 0)
		return (0);
	if (param[0][0] == '.' || param[0][0] == '/')
	{
		if (access(param[0], X_OK) == 0)
		{
			pid = fork();
			if (pid > 0)
				waitpid(pid, &status, 0);
			if (pid == 0)
				execve(param[0], param, env);
			return (1);
		}
	}
	return (0);
}