From 99e25705e86fc35752535b7142632315187d9a05 Mon Sep 17 00:00:00 2001 From: narnaud Date: Tue, 17 May 2022 16:40:00 +0200 Subject: [PATCH] a fix --- caller.c | 7 ++++--- parser.c | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/caller.c b/caller.c index 5ac479b..92a9482 100755 --- a/caller.c +++ b/caller.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ -/* Updated: 2022/05/17 15:45:59 by mea ### ########.fr */ +/* Updated: 2022/05/17 16:28:32 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -117,9 +117,10 @@ int caller(t_datas *datas, t_command *cmd) close(cmd->fd[1]); if (cmd->ope == PIPE) caller(datas, cmd->next); - else + waitpid(cmd->pid, &status, 0); + if (cmd->ope != PIPE) { - if (!is_builtin(cmd->argv[0]) && waitpid(cmd->pid, &status, 0)) + if (!is_builtin(cmd->argv[0])) datas->exit_code = handle_status(datas, status); while (cmd->next && !((cmd->ope == AND && !datas->exit_code) \ || (cmd->ope == OR && datas->exit_code))) diff --git a/parser.c b/parser.c index dad8e5a..3d5bb3d 100755 --- a/parser.c +++ b/parser.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 16:09:25 by narnaud #+# #+# */ -/* Updated: 2022/05/17 15:52:40 by mea ### ########.fr */ +/* Updated: 2022/05/17 16:35:56 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,11 +18,9 @@ static t_token *parse_cmd(t_datas *datas, t_token *tok, t_command *cmd); t_command *parser(t_datas *datas, t_token *tok, t_command *prev) { t_command *cmd; - int syntax_err; + int lex_succ; - syntax_err = 0; - if (!tok) - syntax_err = 1; + lex_succ = ((tok && 1) || 0); cmd = ft_calloc(1, sizeof(*cmd)); if (prev) cmd->prev = prev; @@ -38,8 +36,11 @@ t_command *parser(t_datas *datas, t_token *tok, t_command *prev) free(tok->value); free(tok); } - if (free_cmd(cmd), syntax_err) + if (!lex_succ) + { + free_cmd(cmd); return (NULL); + } return (cmd); }