Attempt to continue after abort

This commit is contained in:
M66B 2017-10-22 09:39:11 +02:00
parent 97f994f075
commit 64e2730525
2 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <setjmp.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>

View File

@ -45,6 +45,14 @@ void clear() {
ng_session = NULL;
}
sighandler_t old_handler;
sigjmp_buf jump;
void handle_sigabrt(int sig) {
old_handler(sig);
siglongjmp(jump, 1);
}
void *handle_events(void *a) {
struct arguments *args = (struct arguments *) a;
log_android(ANDROID_LOG_WARN, "Start events tun=%d thread %x", args->tun, thread_id);
@ -106,9 +114,17 @@ void *handle_events(void *a) {
stopping = 1;
}
old_handler = signal(SIGABRT, handle_sigabrt);
// Loop
long long last_check = 0;
while (!stopping) {
if (sigsetjmp(jump, 1)) {
log_android(ANDROID_LOG_WARN, "Continuing after abort");
if (stopping)
break;
}
log_android(ANDROID_LOG_DEBUG, "Loop thread %x", thread_id);
int recheck = 0;
@ -287,6 +303,8 @@ void *handle_events(void *a) {
}
}
signal(SIGABRT, old_handler);
// Close epoll file
if (epoll_fd >= 0 && close(epoll_fd))
log_android(ANDROID_LOG_ERROR,