can't figure out why it returns wrong value

This commit is contained in:
mdev9
2024-03-24 10:00:09 +01:00
parent bedf72b553
commit a58366f827
8 changed files with 28 additions and 194 deletions

View File

@ -6,11 +6,12 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/03/23 19:04:17 by tomoron ### ########.fr */
/* Updated: 2024/03/24 09:59:16 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include <sys/wait.h>
int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
{
@ -43,7 +44,7 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
void exec_command(t_msh *msh, int i, int cmd_count)
{
g_return_code = 0;
//g_return_code = 0;
msh->fds[i] = ft_calloc(2, sizeof(int *));
if (!msh->fds[i])
ft_exit(msh, 1);
@ -85,9 +86,15 @@ void exec_commands(t_msh *msh)
while (i < cmd_count)
{
waitpid(msh->pids[i], &status, 0);
g_return_code = WEXITSTATUS(status);
//if (/*!g_return_code*/i == cmd_count - 1)
//{
//ft_printf_fd(2, "old: %d, new: %d\n", g_return_code, WEXITSTATUS(status));
//ft_printf_fd(2, "replace value\n");
//g_return_code = WEXITSTATUS(status);
//}
i++;
}
g_return_code = WEXITSTATUS(status);
i = 0;
while (i < cmd_count)
{