Moved the interpreter
[repair.git] / Repair / RepairInterpreter / catcherror.c
diff --git a/Repair/RepairInterpreter/catcherror.c b/Repair/RepairInterpreter/catcherror.c
new file mode 100755 (executable)
index 0000000..9fd8a31
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdlib.h>
+#include "catcherror.h"
+
+struct StackElement * stackptr=NULL;
+
+void handler(int signal) {
+  jmp_buf *jb=(jmp_buf *)popstack(&stackptr);
+  if (jb==NULL) {
+    printf("Signal %d\n",signal);
+    exit(-1);
+  }
+  longjmp(*jb,1);
+}
+
+void installhandlers() {
+  signal(SIGSEGV,&handler);
+  signal(SIGFPE,&handler);
+}