whatthecommit.com’s server IP address could not be found.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/03 17:46:14 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/03 19:37:44 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -57,7 +57,8 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
||||
print_parsed_token(msh->tokens); // debug
|
||||
exec_commands(msh);
|
||||
}
|
||||
while(cmds && (is_cmd_type(cmds) || cmds->cmd_type == PIPE))
|
||||
while (cmds && (is_cmd_type(cmds) || cmds->cmd_type == PIPE
|
||||
|| is_output_type(cmds) || is_input_type(cmds)))
|
||||
cmds = cmds->next;
|
||||
}
|
||||
}
|
||||
@ -103,6 +104,20 @@ void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
remove_command_from_msh(msh);
|
||||
}
|
||||
|
||||
int get_cmd_count(t_cmd *cmds)
|
||||
{
|
||||
int nb;
|
||||
|
||||
nb = 0;
|
||||
while (cmds && !is_operand_type(cmds))
|
||||
{
|
||||
if (is_cmd_type(cmds))
|
||||
nb++;
|
||||
cmds = cmds->next;
|
||||
}
|
||||
return (nb);
|
||||
}
|
||||
|
||||
void end_execution(t_msh *msh, int cmd_count)
|
||||
{
|
||||
int i;
|
||||
@ -123,25 +138,11 @@ void end_execution(t_msh *msh, int cmd_count)
|
||||
set_echoctl(0);
|
||||
}
|
||||
|
||||
int get_cmd_count(t_cmd *cmds)
|
||||
{
|
||||
int nb;
|
||||
|
||||
nb = 0;
|
||||
while(cmds && !is_operand_type(cmds))
|
||||
{
|
||||
if(is_cmd_type(cmds))
|
||||
nb++;
|
||||
cmds = cmds->next;
|
||||
}
|
||||
return(nb);
|
||||
}
|
||||
|
||||
void exec_commands(t_msh *msh)
|
||||
{
|
||||
int cmd_count;
|
||||
int i;
|
||||
int status;
|
||||
|
||||
if (!msh->tokens)
|
||||
return ;
|
||||
@ -150,32 +151,12 @@ void exec_commands(t_msh *msh)
|
||||
msh->pids = ft_calloc(cmd_count, sizeof(int *));
|
||||
if (!msh->pids || !msh->fds)
|
||||
ft_exit(msh, 1);
|
||||
|
||||
i = 0;
|
||||
while (i < cmd_count)
|
||||
{
|
||||
exec_command(msh, i, cmd_count);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (i < cmd_count)
|
||||
{
|
||||
waitpid(msh->pids[i], &status, 0);
|
||||
i++;
|
||||
}
|
||||
if (!g_return_code && WIFEXITED(status))
|
||||
g_return_code = WEXITSTATUS(status);
|
||||
i = 0;
|
||||
while (i < cmd_count)
|
||||
{
|
||||
free(msh->fds[i]);
|
||||
msh->fds[i] = 0;
|
||||
i++;
|
||||
}
|
||||
free(msh->fds);
|
||||
msh->fds = 0;
|
||||
free(msh->pids);
|
||||
msh->pids = 0;
|
||||
//signal(SIGINT, signal_handler_interactive);
|
||||
signal(SIGQUIT, signal_handler_interactive);
|
||||
end_execution(msh, cmd_count);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/03 15:46:12 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/03 19:29:29 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/03 17:21:41 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/03 19:07:32 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/01 20:10:09 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/03 19:23:33 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -57,12 +57,16 @@ int set_echoctl(int value)
|
||||
{
|
||||
struct termios t_p;
|
||||
|
||||
ft_printf("echoctl value : %d\n",value);
|
||||
if (tcgetattr(1, &t_p))
|
||||
{
|
||||
ft_printf_fd(2, "minishell: an error occured while setting the local fl\
|
||||
ags");
|
||||
ft_printf_fd(2, "minishell: an error occured while getting the local fl\
|
||||
ags\n");
|
||||
return (1);
|
||||
}
|
||||
if (((t_p.c_lflag & ECHOCTL) != 0) == value)
|
||||
return (0);
|
||||
ft_printf("change\n");
|
||||
if (value)
|
||||
t_p.c_lflag = t_p.c_lflag | ECHOCTL;
|
||||
else
|
||||
@ -70,7 +74,7 @@ ags");
|
||||
if (tcsetattr(1, TCSANOW, &t_p))
|
||||
{
|
||||
ft_printf_fd(2, "minishell: an error occured while setting the local fl\
|
||||
ags");
|
||||
ags\n");
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
Reference in New Issue
Block a user