added SIGINT and SIGTERM handling to unix client and server.

either signal causes the main thread to be cancelled.  added
necessary code to make main thread cancellation clean up
nicely.
This commit is contained in:
crs
2002-06-02 18:49:35 +00:00
parent 1da9be88c9
commit 1d3807cb0e
7 changed files with 115 additions and 25 deletions

View File

@@ -6,11 +6,12 @@
#include "ISecondaryScreen.h"
#include "ProtocolTypes.h"
#include "CLock.h"
#include "CLog.h"
#include "CThread.h"
#include "CTimerThread.h"
#include "XSynergy.h"
#include "TMethodJob.h"
#include "CLog.h"
#include "XSynergy.h"
#include "XThread.h"
#include <assert.h>
#include <memory>
@@ -71,6 +72,7 @@ void CClient::run(const CNetworkAddress& serverAddress)
log((CLOG_ERR "client error: %s", e.what()));
// clean up
log((CLOG_NOTE "stopping client"));
if (thread != NULL) {
thread->cancel();
thread->wait();
@@ -78,10 +80,22 @@ void CClient::run(const CNetworkAddress& serverAddress)
}
closeSecondaryScreen();
}
catch (XThread&) {
// clean up
log((CLOG_NOTE "stopping client"));
if (thread != NULL) {
thread->cancel();
thread->wait();
delete thread;
}
closeSecondaryScreen();
throw;
}
catch (...) {
log((CLOG_DEBUG "unknown client error"));
// clean up
log((CLOG_NOTE "stopping client"));
if (thread != NULL) {
thread->cancel();
thread->wait();