fix: signal set exit code

This commit is contained in:
Camille Chauvet 2023-03-28 14:38:10 +02:00
parent db51c3c85b
commit 67e8a60423

11
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/02/24 11:04:40 by cchauvet ### ########.fr */
/* Updated: 2023/03/28 14:35:13 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -99,6 +99,10 @@ void ft_ctrlc(int num)
{
t_data *data;
if (num == SIGQUIT)
return ;
data = ft_get_data();
data->exit_code = 130;
if (*ft_get_heredoc() != -1)
{
close(*ft_get_heredoc());
@ -106,10 +110,8 @@ void ft_ctrlc(int num)
}
else
{
data = ft_get_data();
if (data->child_pid > 1)
{
kill(data->child_pid, num);
data->child_pid = 0;
ft_putchar_fd('\n', 1);
}
@ -127,10 +129,11 @@ void ft_quit(int num)
{
t_data *data;
(void) num;
data = ft_get_data();
data->exit_code = 131;
if (data->child_pid > 1)
{
kill(data->child_pid, num);
ft_printf("Quit (core dumped)\n");
data->child_pid = 0;
}