Index: Evidence/Evidence.cc
===================================================================
--- Evidence/Evidence.cc	(revision 229)
+++ Evidence/Evidence.cc	(revision 231)
@@ -10,8 +10,8 @@
     this severity, the call to Message() is guranteed not to return).
   - Configuration data can be requested by GetConfig() and non-blocking by GetConfigNB().
-  - If the configuration file changes the signal SIGUSR1 is emitted which is caught by the standard
+  - If the configuration file changes a signal can be emitted which is caught by the standard
     signal handler. The handler invokes ConfigChanged() which can be redefined by the user application.
 	The signal is delivered only to the main thread (where the constructor is executed) and thus
-	blocking rpc can be made from it.
+	blocking rpc can be made from it. The signal is set using ActivateSignal().
   - Signal handlers to ignore common signals are installed.
     These signals will then cause pause() to return which can be used
@@ -45,5 +45,5 @@
   ConfigTimeStamp = 0;
   
-  // SIGUSR2 delivered to this thread if configuration file changes 
+  // Signal delivered to this thread if configuration file changes 
   ThreadID = pthread_self();
 
@@ -70,6 +70,6 @@
   Unlock();
 
-  if (pthread_kill(ThreadID, SIGUSR2) != 0) {
-	ThisServer->Message(ThisServer->WARN, "Could not send signal SIGUSR2 to main thread");
+  if (pthread_kill(ThreadID, ThisServer->ConfigSignal) != 0) {
+	ThisServer->Message(ThisServer->WARN, "Could not send signal to main thread");
   }
 }
@@ -111,5 +111,5 @@
 	}
 	else {
-	  if (Config.getSize() == 0) Result = Default;
+	  if (Config.getSize() <= 1) Result = Default;
 	  else Result = string(Config.getString(), Config.getSize()-1); // Retrieve string safely
     }
@@ -143,13 +143,16 @@
 }
 
-// Locking and unlocking for list access. Signal SIGUSR2 is also blocked.
+// Locking and unlocking for list access
+// Signal blocked before locking to avaoid dead-lock by calling GetConfig() from ConfigChanged().
 void EvidenceServer::Config::Lock() {
 
   int Ret = 0;
   sigset_t Set;
-  //printf("Locking %u\n", pthread_self());
-  Ret += abs(sigemptyset(&Set));
-  Ret += abs(sigaddset(&Set, SIGUSR2));
-  Ret += abs(pthread_sigmask(SIG_BLOCK, &Set, NULL));
+
+  if (ThisServer->ConfigSignal != 0) {
+	Ret += abs(sigemptyset(&Set));
+	Ret += abs(sigaddset(&Set, ThisServer->ConfigSignal));
+	Ret += abs(pthread_sigmask(SIG_BLOCK, &Set, NULL));
+  }
   Ret += abs(pthread_mutex_lock(&Mutex));
   
@@ -163,10 +166,11 @@
   int Ret = 0;
   sigset_t Set;
-  //printf("  Unlocking %u\n", pthread_self());
 
   Ret += abs(pthread_mutex_unlock(&Mutex));
-  Ret += abs(sigemptyset(&Set));
-  Ret += abs(sigaddset(&Set, SIGUSR2));
-  Ret += abs(pthread_sigmask(SIG_UNBLOCK, &Set, NULL));
+  if (ThisServer->ConfigSignal != 0) {
+	Ret += abs(sigemptyset(&Set));
+	Ret += abs(sigaddset(&Set, ThisServer->ConfigSignal));
+	Ret += abs(pthread_sigmask(SIG_UNBLOCK, &Set, NULL));
+  }
 
   if (Ret != 0) {
@@ -179,4 +183,6 @@
 // EvidenceServer Class //
 //////////////////////////
+
+int EvidenceServer::ConfigSignal = 0;
 
 // Constructor starts server with given name
@@ -195,13 +201,8 @@
   signal(SIGHUP, &SignalHandler);   // Terminal closed
   
-  struct sigaction S;
-  S.sa_handler = &SignalHandler;
-  S.sa_flags = SA_RESTART;
-  sigaction(SIGUSR2, &S, NULL);
-
   // Catch C++ unhandled exceptions
   set_terminate(Terminate);
 
-  // Configuration class (instantiate after signal handling for SIGUSR2 installed)
+  // Configuration class (must be instantiate after signal handling installed)
   ConfClass = new class Config(Name);
 
@@ -310,4 +311,16 @@
 }
 
+// Signal emitted when configuraton file changes, signal handler calls ConfigChanged()
+void EvidenceServer::ActivateSignal(int Signal) {
+
+  struct sigaction S;
+
+  ConfigSignal = Signal;
+  S.sa_handler = &SignalHandler;
+  S.sa_flags = SA_RESTART;
+  sigaction(Signal, &S, NULL);
+}
+
+
 // ====== Static methods ======
 
@@ -317,6 +330,6 @@
   static bool Called = false;
 
-  // If SIGUSR2, invoke call-back for configuraton change
-  if (Signal == SIGUSR2) {
+  // If signal indicates configuration change, invoke call-back
+  if (Signal == EvidenceServer::ConfigSignal) {
     ThisServer->ConfigChanged();
 	return;
@@ -338,11 +351,11 @@
 void EvidenceServer::Terminate() {
 
-  static char Msg[STATUS_SIZE];
+  ostringstream Msg;
   static bool Terminating = false;
 
   if (Terminating) {
-	snprintf(Msg, sizeof(Msg), "%s: Terminate() called recursively, calling abort()", ThisServer->MessageService->getName());
-	printf("%s\n", Msg);
-	DimClient::sendCommandNB("DColl/Log", Msg);
+	Msg << ThisServer->Name << ": Terminate() called recursively, calling abort()";
+	printf("%s\n", Msg.str().c_str());
+	ThisServer->SendToLog(Msg.str().c_str());
 	abort();
   }
@@ -358,5 +371,5 @@
 
 	Demangled = abi::__cxa_demangle(Type->name(), 0, 0, &Status);
-	snprintf(Msg, sizeof(Msg), "Terminate() called after throwing an instance of '%s'", Status==0 ? Demangled : Type->name());
+	Msg << "Terminate() called after throwing an instance of '" << (Status==0 ? Demangled : Type->name()) << "'";
 	free(Demangled);
 
@@ -364,11 +377,11 @@
 	try { __throw_exception_again; }
 	catch (exception &E) {
-	  snprintf(Msg+strlen(Msg), sizeof(Msg)-strlen(Msg), " (what(): %s)", E.what());	  
+	  Msg << " (what(): " << E.what() << ")";	  
 	}
 	catch (...) { }
   }
-  else snprintf(Msg, sizeof(Msg), "Terminate() called without an active exception");
-
-  ThisServer->Message(FATAL, Msg);
+  else Msg << "Terminate() called without an active exception";
+
+  ThisServer->Message(FATAL, Msg.str().c_str());
 }
 
