termux-packages/x11-packages/tigervnc-viewer/common-os-Thread.cxx.patch

46 lines
924 B
Diff

--- a/common/os/Thread.cxx
+++ b/common/os/Thread.cxx
@@ -29,6 +29,14 @@
#include <os/Mutex.h>
#include <os/Thread.h>
+#ifdef __ANDROID__
+#include <string.h>
+static void threadSignalHandler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
using namespace os;
Thread::Thread() : running(false), threadId(NULL)
@@ -48,7 +56,11 @@
delete (HANDLE*)threadId;
#else
if (isRunning())
+#ifdef __ANDROID__
+ pthread_kill(*(pthread_t*)threadId, SIGUSR2);
+#else
pthread_cancel(*(pthread_t*)threadId);
+#endif
delete (pthread_t*)threadId;
#endif
@@ -148,6 +160,15 @@
void* Thread::startRoutine(void* data)
#endif
{
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = threadSignalHandler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
Thread *self;
self = (Thread*)data;