+#endif
+/******************************************************************************/
+#if !WITH_SIG_MONITOR_FOR_CALL
+
+static inline void monitor_raise(int signum) {}
+
+#else
+
+#include <setjmp.h>
+
+/* local handler */
+static _Thread_local sigjmp_buf *error_handler;
+
+static void monitor(int timeout, void (*function)(int sig, void*), void *arg)
+{
+ volatile int signum, signum2;
+ sigjmp_buf jmpbuf, *older;
+
+ older = error_handler;
+ signum = setjmp(jmpbuf);
+ if (signum == 0) {
+ error_handler = &jmpbuf;
+ if (timeout) {
+ timeout_create();
+ timeout_arm(timeout);
+ }
+ function(0, arg);
+ } else {
+ signum2 = setjmp(jmpbuf);
+ if (signum2 == 0)
+ function(signum, arg);
+ }
+ if (timeout)
+ timeout_disarm();
+ error_handler = older;
+}
+
+static inline void monitor_raise(int signum)
+{
+ if (error_handler != NULL)
+ longjmp(*error_handler, signum);
+}
+#endif
+/******************************************************************************/
+#if !WITH_SIG_MONITOR_SIGNALS
+
+static inline int enable_signal_handling() { return 0; }
+
+#else
+
+#include <signal.h>
+
+/* internal signal lists */
+static int sigerr[] = { SIGSEGV, SIGFPE, SIGILL, SIGBUS, SIG_FOR_TIMER, 0 };
+static int sigterm[] = { SIGINT, SIGABRT, SIGTERM, 0 };
+
+static int exiting = 0;
+static int enabled = 0;