Commit e9843cfa authored by Kevin Modzelewski's avatar Kevin Modzelewski

Have the gdb watcher catch SIGABRT as well

parent 9f82d935
...@@ -60,12 +60,7 @@ static bool unbuffered = false; ...@@ -60,12 +60,7 @@ static bool unbuffered = false;
static const char* argv0; static const char* argv0;
static int pipefds[2]; static int pipefds[2];
static void handle_sigsegv(int signum) { static void signal_parent_watcher() {
assert(signum == SIGSEGV);
// TODO: this should set a flag saying a KeyboardInterrupt is pending.
// For now, just call abort(), so that we get a traceback at least.
fprintf(stderr, "child encountered segfault! signalling parent watcher to backtrace.\n");
char buf[1]; char buf[1];
int r = write(pipefds[1], buf, 1); int r = write(pipefds[1], buf, 1);
RELEASE_ASSERT(r == 1, ""); RELEASE_ASSERT(r == 1, "");
...@@ -75,6 +70,20 @@ static void handle_sigsegv(int signum) { ...@@ -75,6 +70,20 @@ static void handle_sigsegv(int signum) {
} }
} }
static void handle_sigsegv(int signum) {
assert(signum == SIGSEGV);
fprintf(stderr, "child encountered segfault! signalling parent watcher to backtrace.\n");
signal_parent_watcher();
}
static void handle_sigabrt(int signum) {
assert(signum == SIGABRT);
fprintf(stderr, "child aborted! signalling parent watcher to backtrace.\n");
signal_parent_watcher();
}
static int gdb_child_pid; static int gdb_child_pid;
static void propagate_sig(int signum) { static void propagate_sig(int signum) {
// fprintf(stderr, "parent received signal %d, passing to child and then ignoring\n", signum); // fprintf(stderr, "parent received signal %d, passing to child and then ignoring\n", signum);
...@@ -136,6 +145,7 @@ static void enableGdbSegfaultWatcher() { ...@@ -136,6 +145,7 @@ static void enableGdbSegfaultWatcher() {
close(pipefds[0]); close(pipefds[0]);
signal(SIGSEGV, &handle_sigsegv); signal(SIGSEGV, &handle_sigsegv);
signal(SIGABRT, &handle_sigabrt);
} }
int handleArg(char code) { int handleArg(char code) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment