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: 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);
}