3 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 // debugging functions go here
27 #include "arraylist.h"
29 #include "bcsignals.inc"
36 // BC_Signals must be initialized at the start of every program using
39 class BC_Signals : public BC_Trace
41 int (*old_err_handler)(Display *, XErrorEvent *);
42 static int x_error_handler(Display *display, XErrorEvent *event);
46 void initialize(const char *trap_path=0);
50 virtual void signal_handler(int signum);
51 static void dump_stack(FILE *fp=stdout);
52 static void signal_dump(int signum);
53 static void kill_subs();
54 static void set_sighup_exit(int enable);
56 static void set_trap_path(const char *path);
57 static void set_trap_hook(void (*hook)(FILE *fp, void *data), void *data);
58 static void set_catch_segv(bool v);
59 static void set_catch_intr(bool v);
61 // Convert signum to text
62 static const char* sig_to_str(int number);
64 static BC_Signals *global_signals;
65 static const char *trap_path;
66 static void *trap_data;
67 static void (*trap_hook)(FILE *fp, void *vp);
68 static bool trap_sigsegv, trap_sigintr;