This commit is contained in:
Maieul BOYER 2024-05-08 15:30:34 +02:00
parent 27eb1f10b1
commit 99f1e58812
No known key found for this signature in database
6 changed files with 57 additions and 17 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/05/07 13:08:24 by maiboyer ### ########.fr */
/* Updated: 2024/05/08 15:27:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -164,6 +164,7 @@ t_i32 main(t_i32 argc, t_str argv[], t_str envp[])
if (install_signal())
return (1);
utils = (t_utils){};
*(t_u8 volatile *)NULL = 5;
utils.env = create_env_map();
utils.parser = create_myparser();
utils.name_shell = "\001\x1B[93m\002"

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */
/* Updated: 2024/05/03 12:23:44 by maiboyer ### ########.fr */
/* Updated: 2024/05/08 15:28:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -50,6 +50,16 @@ void sigquit_handle(int sig, siginfo_t *info, void *ucontext)
}
}
void sigsegv_handle(int sig, siginfo_t *info, void *ucontext)
{
(void)(sig);
(void)(info);
(void)(ucontext);
printf("SEGFAULT!!!\n");
print_trace();
exit(139);
}
t_error install_signal(void)
{
struct sigaction data;
@ -63,6 +73,9 @@ t_error install_signal(void)
data.sa_sigaction = sigquit_handle;
if (sigaction(SIGQUIT, &data, NULL))
return (ERROR);
data.sa_sigaction = sigsegv_handle;
if (sigaction(SIGSEGV, &data, NULL))
return (ERROR);
return (NO_ERROR);
}