Skip to contentSkip to conversation

multi-process: util: Add qemu_thread_cancel() to cancel running thread

RFC PATCH Superseded [email protected] 1 participant 1 message Mar 7, 2019

v1 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/37 multi-process: util: Add qemu_thread_cancel() to cancel running thread

From: Jagannathan Raman <[email protected]>

qemu_thread_cancel() added to destroy a given running thread. This will be needed in the following patches.

---
 include/qemu/thread.h    |  1 +
 util/qemu-thread-posix.c | 10 ++++++++++
 2 files changed, 11 insertions(+)
include/qemu/thread.h +1 -0
index 55d83a9..78791be 100644
@@ -156,6 +156,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,
                         void *(*start_routine)(void *),
                         void *arg, int mode);
 void *qemu_thread_join(QemuThread *thread);
+void qemu_thread_cancel(QemuThread *thread);
 void qemu_thread_get_self(QemuThread *thread);
 bool qemu_thread_is_self(QemuThread *thread);
 void qemu_thread_exit(void *retval);
util/qemu-thread-posix.c +10 -0
index 1bf5e65..7c89071 100644
@@ -573,3 +573,13 @@ void *qemu_thread_join(QemuThread *thread)
     }
     return ret;
 }
+
+void qemu_thread_cancel(QemuThread *thread)
+{
+    int err;
+
+    err = pthread_cancel(thread->thread);
+    if (err) {
+        error_exit(err, __func__);
+    }
+}
Signature · 1 line
1.8.3.1