clean: norm part2 (FINAL)
This commit is contained in:
65
signal/signal.c
Normal file
65
signal/signal.c
Normal file
@ -0,0 +1,65 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* signal.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/28 15:59:01 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/03/28 16:09:37 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "signal_private.h"
|
||||
|
||||
static void ft_new_line(void)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
19
signal/signal.h
Normal file
19
signal/signal.h
Normal file
@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* signal.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/28 16:02:31 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/03/28 16:03:11 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SIGNAL_H
|
||||
# define SIGNAL_H
|
||||
|
||||
void ft_quit(int num);
|
||||
void ft_ctrlc(int num);
|
||||
|
||||
#endif
|
21
signal/signal_private.h
Normal file
21
signal/signal_private.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* signal_private.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SIGNAL_PRIVATE_H
|
||||
# define SIGNAL_PRIVATE_H
|
||||
# include <signal.h>
|
||||
# include <readline/readline.h>
|
||||
# include <unistd.h>
|
||||
# include "../libftx/libftx.h"
|
||||
# include "../data/data.h"
|
||||
# include "../redirection/redirection.h"
|
||||
#endif
|
Reference in New Issue
Block a user