Commit a9a5022a authored by abenoit's avatar abenoit
Browse files

interupt correct behaviour

parent 84e82549
......@@ -51,6 +51,7 @@
# define CHILD 0x08
# define EXIT_ABORT 0x10
# define EXIT_FLAG 0x20
# define INTERUPT 0x40
/*
** **********************************
......
......@@ -57,7 +57,12 @@ int handle_pipe(t_command *cur_command, t_xe *xe, int fd_in, int proc)
if (close(fd[1]) == ERROR || close(fd_in) == ERROR)
return (FD_ERROR);
free_command(cur_command);
return (handle_execution(xe, fd[0], proc + 1));
if (!(xe->flags & INTERUPT))
return (handle_execution(xe, fd[0], proc + 1));
else {
xe->flags = RUN;
return (SUCCESS);
}
}
}
......@@ -72,7 +77,12 @@ int handle_command(t_command *cur_command, t_xe *xe,
free_command(cur_command);
dup2(xe->backup_stdout, STDOUT_FILENO);
dup2(xe->backup_stdin, STDIN_FILENO);
return (handle_execution(xe, STDIN_FILENO, 0));
if (!(xe->flags & INTERUPT))
return (handle_execution(xe, STDIN_FILENO, 0));
else {
xe->flags = RUN;
return (SUCCESS);
}
}
else if (cur_command->pipe_flag == TRUE)
{
......@@ -96,7 +106,12 @@ static int check_redir_type(t_command *cur_command, t_xe *xe,
dup2(xe->backup_stdout, STDOUT_FILENO);
dup2(xe->backup_stdin, STDIN_FILENO);
xe->stat_loc = 1;
return (handle_execution(xe, fd_in, proc));
if (!(xe->flags & INTERUPT))
return (handle_execution(xe, fd_in, proc));
else {
xe->flags = RUN;
return (SUCCESS);
}
}
if (cur_command->args == NULL)
{
......@@ -107,7 +122,12 @@ static int check_redir_type(t_command *cur_command, t_xe *xe,
return (FD_ERROR);
}
free_command(cur_command);
return (handle_execution(xe, fd_in, proc));
if (!(xe->flags & INTERUPT))
return (handle_execution(xe, fd_in, proc));
else {
xe->flags = RUN;
return (SUCCESS);
}
}
return (KEEP_ON);
}
......
......@@ -28,7 +28,10 @@ static int exec_parent_end(pid_t *pid, t_xe *xe)
if (xe->stat_loc == SIGQUIT)
ft_putstr_fd("\b\b^\\Quit (core dumped)\n", STDERR_FILENO);
else if (xe->stat_loc == SIGINT)
{
xe->flags += INTERUPT;
ft_putstr_fd("\n", STDERR_FILENO);
}
xe->stat_loc += 128;
}
else if (WIFEXITED(xe->stat_loc))
......
......@@ -98,6 +98,12 @@ int parent_pipe_end(t_command *cur_command, t_xe *xe,
ft_error(ret, xe);
if (ret == EXIT_ARG_ERR)
return (SUCCESS);
return (handle_execution(xe, STDIN_FILENO, 0));
if (!(xe->flags & INTERUPT))
return (handle_execution(xe, STDIN_FILENO, 0));
else
{
xe->flags = RUN;
return (SUCCESS);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment