Skip to content

Commit

Permalink
main/init: add SIGSEGV, SIGABRT and SIGILL handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Apr 15, 2023
1 parent ae7d147 commit c3be915
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,33 @@
*
* Copyright (C) 2010 Creytiv.com
*/
#include <stdlib.h>
#ifdef HAVE_SIGNAL
#include <signal.h>
#endif
#include <re_types.h>
#include <re_fmt.h>
#include <re_list.h>
#include <re_net.h>
#include <re_sys.h>
#include <re_main.h>
#include <re_btrace.h>
#include "main.h"


#ifdef HAVE_SIGNAL
static void signal_handler(int sig)
{
struct btrace bt;

btrace(&bt);
re_fprintf(stderr, "Signal (%d) %H\n", sig, btrace_println, &bt);

exit(128 + sig);
}
#endif


/**
* Initialise main library
*
Expand All @@ -21,6 +39,12 @@ int libre_init(void)
{
int err;

#ifdef HAVE_SIGNAL
(void)signal(SIGSEGV, signal_handler);
(void)signal(SIGABRT, signal_handler);
(void)signal(SIGILL, signal_handler);
#endif

#ifdef USE_OPENSSL
err = openssl_init();
if (err)
Expand Down

0 comments on commit c3be915

Please sign in to comment.