From 5ed2af680d89d8643530f5e9f26ccb832e6bad3e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 13 May 2008 19:42:57 +0000 Subject: added extra catch for std::runtime_error --- src/Makefile | 2 ++ src/anytun.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Makefile b/src/Makefile index 8046245..eca9774 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,6 +11,8 @@ LD = g++ LDFLAGS = -g -Wall -O2 -lpthread -lgcrypt -lgpg-error -lboost_serialization ifeq ($(TARGET),Linux) +# CFLAGS += -D_XOPEN_SOURCE=600 +# CCFLAGS += -D_XOPEN_SOURCE=600 LDFLAGS += -ldl endif ifeq ($(TARGET),OpenBSD) diff --git a/src/anytun.cpp b/src/anytun.cpp index 3d985d4..ed6d845 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -191,6 +191,10 @@ void* sender(void* p) } } } + catch(std::runtime_error e) + { + cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught runtime_error: " << e.what(); + } catch(std::exception e) { cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught exception: " << e.what(); @@ -323,6 +327,10 @@ void* receiver(void* p) param->dev.write(plain_packet.getPayload(), plain_packet.getLength()); } } + catch(std::runtime_error e) + { + cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught runtime_error: " << e.what(); + } catch(std::exception e) { cLog.msg(Log::PRIO_ERR) << "receiver thread died due to an uncaught exception: " << e.what(); @@ -567,6 +575,13 @@ int main(int argc, char* argv[]) return ret; } + catch(std::runtime_error e) + { + if(daemonized) + cLog.msg(Log::PRIO_ERR) << "uncaught runtime error, exiting: " << e.what(); + else + std::cout << "uncaught runtime error, exiting: " << e.what() << std::endl; + } catch(std::exception e) { if(daemonized) -- cgit v1.2.3