summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-09-29 11:24:19 +0200
committerPierre Ossman <ossman@cendio.se>2018-11-09 17:25:23 +0100
commit10688efcf759f24e83814f9e12a1275296b07a4c (patch)
tree51d46d026e8cc9c04aae739e52582c6566c45112 /unix
parentf43137c61bd19fd3a7a51833c9eb9bb9f890a904 (diff)
downloadtigervnc-10688efcf759f24e83814f9e12a1275296b07a4c.tar.gz
tigervnc-10688efcf759f24e83814f9e12a1275296b07a4c.zip
Properly terminate server on timeouts
Do a proper cleanup when one of the termination timeouts trigger rather than just exiting on the spot. This makes sure we don't leave stray stuff around, e.g. unix socket files.
Diffstat (limited to 'unix')
-rw-r--r--unix/x0vncserver/XDesktop.cxx6
-rw-r--r--unix/x0vncserver/XDesktop.h1
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc6
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h1
4 files changed, 14 insertions, 0 deletions
diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx
index 9a047c8e..3e67fad0 100644
--- a/unix/x0vncserver/XDesktop.cxx
+++ b/unix/x0vncserver/XDesktop.cxx
@@ -19,6 +19,8 @@
*/
#include <assert.h>
+#include <signal.h>
+#include <unistd.h>
#include <rfb/LogWriter.h>
@@ -273,6 +275,10 @@ void XDesktop::stop() {
pb = 0;
}
+void XDesktop::terminate() {
+ kill(getpid(), SIGTERM);
+}
+
bool XDesktop::isRunning() {
return running;
}
diff --git a/unix/x0vncserver/XDesktop.h b/unix/x0vncserver/XDesktop.h
index 7d060613..3e85aac3 100644
--- a/unix/x0vncserver/XDesktop.h
+++ b/unix/x0vncserver/XDesktop.h
@@ -49,6 +49,7 @@ public:
// -=- SDesktop interface
virtual void start(rfb::VNCServer* vs);
virtual void stop();
+ virtual void terminate();
bool isRunning();
virtual void queryConnection(network::Socket* sock,
const char* userName);
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index e61472b3..d4891c3a 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -22,6 +22,7 @@
//
#include <assert.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
@@ -423,6 +424,11 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
// SDesktop callbacks
+void XserverDesktop::terminate()
+{
+ kill(getpid(), SIGTERM);
+}
+
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
{
vncPointerMove(pos.x + vncGetScreenX(screenIndex),
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index ff36b3b5..1253935f 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -87,6 +87,7 @@ public:
// rfb::SDesktop callbacks
virtual void start(rfb::VNCServer* vs);
virtual void stop();
+ virtual void terminate();
virtual void queryConnection(network::Socket* sock,
const char* userName);
virtual void pointerEvent(const rfb::Point& pos, int buttonMask);