Index: include/defs/gis.h
===================================================================
--- include/defs/gis.h	(revision 60521)
+++ include/defs/gis.h	(working copy)
@@ -60,6 +60,7 @@
 
 #include <stdarg.h>
 #include <stdio.h>
+#include <setjmp.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -217,6 +218,7 @@
 void G_switch_env(void);
 
 /* error.c */
+jmp_buf *G_fatal_longjmp(int);
 int G_info_format(void);
 void G_message(const char *, ...) __attribute__ ((format(printf, 1, 2)));
 void G_verbose_message(const char *, ...)
Index: lib/gis/error.c
===================================================================
--- lib/gis/error.c	(revision 60521)
+++ lib/gis/error.c	(working copy)
@@ -14,6 +14,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <setjmp.h>
 #include <unistd.h>
 #include <time.h>
 #include <stdarg.h>
@@ -57,6 +58,15 @@
 static int write_error(const char *, int, time_t, const char *);
 static void log_error(const char *, int);
 
+static int fatal_longjmp;
+static jmp_buf fatal_jmp_buf;
+
+jmp_buf *G_fatal_longjmp(int enable)
+{
+    fatal_longjmp = enable;
+    return &fatal_jmp_buf;
+}
+
 static void vfprint_error(int type, const char *template, va_list ap)
 {
     char buffer[2000];		/* G_asprintf does not work */
@@ -158,6 +168,11 @@
         va_end(ap);
     }
 
+    if (fatal_longjmp) {
+	busy = 0;
+	longjmp(fatal_jmp_buf, 1);
+    }
+
     G__call_error_handlers();
 
     /* Raise SIGABRT, useful for debugging only.
