Esempio n. 1
0
static void		mshell(char **env)
{
	char	*line;
	char 	**av;
	pid_t	father;

	(void)env;
	while (get_next_line(0, &line) > 0)
	{
		father = fork();
		if (father != 0)
		{
			signal(SIGUSR1, sig_handler);
			wait(&father);
		}
		else
		{
			av = sh_lexer(&line);
		}
		free(line);
		ft_prompt(PROMPT, BLUE);
	}
}
Esempio n. 2
0
File: main.c Progetto: sbenning42/42
void			sh_loop(t_sh *sh)
{
	t_lxem		*lexem_list;
	t_tree		*cmd_tree;

	while (42)
	{
		if (sh_readline(sh) < 0)												//Get the user command line
		{
			*gg_status() = 0;														//Default command status is set to 1 // BUG-02: gg_status() must be in the t_sh structure
			continue ;
		}
		*gg_status() = 1;														//Default command status is set to 1 // BUG-02: gg_status() must be in the t_sh structure
		if (sh_lexer(sh, &lexem_list) < 0)										//Split the line into lexem
			continue ;
		if (sh_parser(sh, &cmd_tree, &lexem_list) < 0)							//Parse the lexem list to get a binary command tree
			continue ;
		*gg_status() = (exec_root(sh, cmd_tree) ? 1 : 0);						//Execute all the command tree and get the status of the execution
		if (ISO(sh->o, SH_O_VERBOSE))											//If '-v' is specified in the arg_v, print a debug of the tree
			dump_root(cmd_tree, 0, sh->bin);
		parse_del(&cmd_tree);													//Clear the memory used by the tree
		ft_memdel((void **)&sh->line);											//Clear the memory used by the command line
	}
}
Esempio n. 3
0
File: main.c Progetto: sbenning42/42
void			sh_loop(t_sh *sh)
{
	t_lxem		*lexem_list;
	t_tree		*cmd_tree;

	while (42)
	{
		if (sh_readline(sh) < 0)
		{
			*gg_status() = 0;
			continue ;
		}
		*gg_status() = 1;
		if (sh_lexer(sh, &lexem_list) < 0)
			continue ;
		if (sh_parser(sh, &cmd_tree, &lexem_list) < 0)
			continue ;
		*gg_status() = (exec_root(sh, cmd_tree) ? 1 : 0);
		if (ISO(sh->o, SH_O_VERBOSE))
			dump_root(cmd_tree, 0, sh->bin);
		parse_del(&cmd_tree);
		ft_memdel((void **)&sh->line);
	}
}