fix: signal

This commit is contained in:
Camille Chauvet
2023-04-05 15:32:04 +00:00
parent e0fb7f1fd0
commit 5d482fc65a
16 changed files with 68 additions and 97 deletions

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
/* Updated: 2023/04/05 12:30:09 by alouis-j ### ########.fr */
/* Updated: 2023/04/05 15:13:33 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,14 +30,14 @@ static int ft_execute_own_cmd(t_data *data, t_cmd *cmd)
return_code = (echo(cmd->fd_out[0], cmd->args + 1));
else
{
return_code = ft_exit(cmd->args + 1, data->exit_code);
return_code = ft_exit(cmd->args + 1, *data->exit_code);
if (return_code >= 0)
{
data->exit_code = return_code;
*data->exit_code = return_code;
return (-2);
}
}
data->exit_code = return_code;
*data->exit_code = return_code;
return (return_code);
}
@ -46,11 +46,11 @@ static bool ft_executor(t_data *data, t_cmd *cmd, char **env)
if (cmd->fd_in[0] == -1 || cmd->fd_out[0] == -1 || cmd->executable == NULL)
return (0);
cmd->pid = fork();
ft_get_data()->child_pid = cmd->pid;
if (cmd->pid == -1)
return (1);
if (cmd->pid == 0)
{
signal(SIGQUIT, ft_quit);
dup2(cmd->fd_in[0], 0);
dup2(cmd->fd_out[0], 1);
ft_lstiter(*data->cmds, ft_cmdcloser);

View File

@ -6,12 +6,14 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:45:53 by cchauvet #+# #+# */
/* Updated: 2023/03/29 18:55:22 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:15:56 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXECUTION_PRIVATE_H
# define EXECUTION_PRIVATE_H
# include <signal.h>
# include "../signal/signal.h"
# include "../data/data.h"
# include "../libftx/libftx.h"
# include "../cmd/cmd.h"