fix: signal
This commit is contained in:
@ -6,61 +6,23 @@
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/28 15:59:01 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/04/05 14:09:39 by alouis-j ### ########.fr */
|
||||
/* Updated: 2023/04/05 15:05:11 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "signal_private.h"
|
||||
|
||||
static void ft_new_line(void)
|
||||
void ft_ctrlc(int num)
|
||||
{
|
||||
(void) num;
|
||||
rl_replace_line("", 0);
|
||||
rl_on_new_line();
|
||||
ft_putchar_fd('\n', 1);
|
||||
rl_redisplay();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (*ft_get_heredoc() > 2)
|
||||
close(*ft_get_heredoc());
|
||||
*ft_get_heredoc() = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data->child_pid > 1)
|
||||
{
|
||||
data->child_pid = 0;
|
||||
ft_putchar_fd('\n', 1);
|
||||
}
|
||||
else
|
||||
ft_new_line();
|
||||
}
|
||||
}
|
||||
|
||||
void ft_quit(int num)
|
||||
{
|
||||
t_data *data;
|
||||
|
||||
(void) num;
|
||||
data = ft_get_data();
|
||||
data->exit_code = 131;
|
||||
if (data->child_pid > 1)
|
||||
{
|
||||
ft_printf("Quit (core dumped)\n");
|
||||
data->child_pid = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rl_replace_line("", 0);
|
||||
rl_redisplay();
|
||||
}
|
||||
ft_printf("Quit (core dumped)\n");
|
||||
}
|
||||
|
@ -6,13 +6,14 @@
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/28 15:59:42 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/03/28 16:04:46 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/04/05 15:05:00 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SIGNAL_PRIVATE_H
|
||||
# define SIGNAL_PRIVATE_H
|
||||
# include <signal.h>
|
||||
# include <stdio.h>
|
||||
# include <readline/readline.h>
|
||||
# include <unistd.h>
|
||||
# include "../libftx/libftx.h"
|
||||
|
Reference in New Issue
Block a user