]> git.proxmox.com Git - qemu.git/blobdiff - qemu-thread-posix.c
Update version for 1.1.0-rc4 release
[qemu.git] / qemu-thread-posix.c
index 49d3388a86286cfda2fa320862f94f73d852985d..9e1b5fbdaa0171e233ef156ac536617510f92274 100644 (file)
@@ -121,17 +121,29 @@ void qemu_thread_create(QemuThread *thread,
 {
     sigset_t set, oldset;
     int err;
+    pthread_attr_t attr;
 
-    assert(mode == QEMU_THREAD_DETACHED);
+    err = pthread_attr_init(&attr);
+    if (err) {
+        error_exit(err, __func__);
+    }
+    if (mode == QEMU_THREAD_DETACHED) {
+        err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+        if (err) {
+            error_exit(err, __func__);
+        }
+    }
 
     /* Leave signal handling to the iothread.  */
     sigfillset(&set);
     pthread_sigmask(SIG_SETMASK, &set, &oldset);
-    err = pthread_create(&thread->thread, NULL, start_routine, arg);
+    err = pthread_create(&thread->thread, &attr, start_routine, arg);
     if (err)
         error_exit(err, __func__);
 
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+
+    pthread_attr_destroy(&attr);
 }
 
 void qemu_thread_get_self(QemuThread *thread)
@@ -148,3 +160,15 @@ void qemu_thread_exit(void *retval)
 {
     pthread_exit(retval);
 }
+
+void *qemu_thread_join(QemuThread *thread)
+{
+    int err;
+    void *ret;
+
+    err = pthread_join(thread->thread, &ret);
+    if (err) {
+        error_exit(err, __func__);
+    }
+    return ret;
+}