Index: /trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp	(revision 41762)
+++ /trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp	(revision 41763)
@@ -48,4 +48,9 @@
 # include <mach/mach_host.h>
 #endif
+#if defined(RT_OS_DARWIN) /*|| defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) - later */ \
+ || defined(IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP)
+# define IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP
+# include <dlfcn.h>
+#endif
 
 #include <iprt/thread.h>
@@ -77,4 +82,28 @@
 static int              g_iSigPokeThread = -1;
 #endif
+
+#ifdef IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP
+# if defined(RT_OS_DARWIN)
+/**
+ * The Mac OS X (10.6 and later) variant of pthread_setname_np.
+ *
+ * @returns errno.h
+ * @param   pszName         The new thread name.
+ */
+typedef int (*PFNPTHREADSETNAME)(const char *pszName);
+# elif
+/**
+ * The variant of pthread_setname_np most other unix-like systems implement.
+ *
+ * @returns errno.h
+ * @param   hThread         The thread.
+ * @param   pszName         The new thread name.
+ */
+typedef int (*PFNPTHREADSETNAME)(pthread_t hThread, const char *pszName);
+# endif
+
+/** Pointer to pthread_setname_np if found. */
+static PFNPTHREADSETNAME g_pfnThreadSetName = NULL;
+#endif /* IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP */
 
 
@@ -143,4 +172,9 @@
     }
 #endif /* RTTHREAD_POSIX_WITH_POKE */
+
+#ifdef IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP
+    if (RT_SUCCESS(rc))
+        g_pfnThreadSetName = (PFNPTHREADSETNAME)(uintptr_t)dlsym(RTLD_DEFAULT, "pthread_setname_np");
+#endif
     return rc;
 }
@@ -245,6 +279,14 @@
 #endif
 
+    /*
+     * Set the TLS entry and, if possible, the thread name.
+     */
     int rc = pthread_setspecific(g_SelfKey, pThread);
     AssertReleaseMsg(!rc, ("failed to set self TLS. rc=%d thread '%s'\n", rc, pThread->szName));
+
+#ifdef IPRT_MAY_HAVE_PTHREAD_SET_NAME_NP
+    if (g_pfnThreadSetName)
+        g_pfnThreadSetName(pThread->szName);
+#endif
 
     /*
