gestion sigint dans heredoc fonctionne basiquement

This commit is contained in:
hugogogo
2021-11-25 10:06:48 +01:00
parent ef12d6ba4b
commit 80410e6d81
11 changed files with 39 additions and 201 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
/* Updated: 2021/11/16 21:18:27 by lperrey ### ########.fr */
/* Updated: 2021/11/18 22:35:07 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -81,14 +81,12 @@ t_cmd **parsing(t_token *token_list)
// 2.9.1 - 3) Redirection
if (!redirections(token_list, cmd_arr))
return (ft_retp_free(NULL, &cmd_arr, (t_free_f)free_pipeline));
// Struct CMD fill
if (!cmd_array_fill_argv(token_list, cmd_arr))
return (ft_retp_free(NULL, &cmd_arr, (t_free_f)free_pipeline));
print_cmd_array(cmd_arr);
// HUGO WIP
// handle_path(cmd_arr, envp);
return (cmd_arr);
}

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/11/18 17:32:32 by hulamy ### ########.fr */
/* Updated: 2021/11/25 10:05:44 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -39,7 +39,9 @@ int here_doc(char *delimiter)
if (!here_doc_write(delimiter, here_doc))
{
free(delimiter);
return (0);
if (unlink(TMP_HERE_DOC) == -1)
return (ft_reti_perror_io(-1, "unlink() ", TMP_HERE_DOC));
return (-1);
}
free(delimiter);
if (close(here_doc) == -1)
@@ -52,6 +54,11 @@ int here_doc(char *delimiter)
return (here_doc);
}
int void_func_return_readline(void)
{
return (0);
}
static int here_doc_write(char *delimiter, int doc_fd)
{
char *line;
@@ -60,12 +67,19 @@ static int here_doc_write(char *delimiter, int doc_fd)
signal_action.sa_handler = sigint_handler_heredoc;
sigaction(SIGINT, &signal_action, NULL);
switch_heredoc_sigint = 0;
rl_event_hook = void_func_return_readline;
line_count = 0;
while (1)
{
line_count++;
line = NULL;
line = readline("> ");
if (switch_heredoc_sigint == 1)
{
// todo : gerer le statut exit 130
return (1);
}
if (!line)
{ // TODO : error print wrapper
ft_putstr_fd("minishell: ", 2);

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */
/* Updated: 2021/11/16 22:29:52 by lperrey ### ########.fr */
/* Updated: 2021/11/18 22:17:44 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */