Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1149)

Unified Diff: base/threading/platform_thread_posix.cc

Issue 8936015: Enable setting thread names on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_posix.cc
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 872cb564c4d1784f6e05742bb5018ff133f63760..9b80af4a214fe8db079d452a951336435c885a8b 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -166,11 +166,7 @@ void PlatformThread::Sleep(int duration_ms) {
sleep_time = remaining;
}
-// Linux SetName is currently disabled, as we need to distinguish between
-// helper threads (where it's ok to make this call) and the main thread
-// (where making this call renames our process, causing tools like killall
-// to stop working).
-#if 0 && defined(OS_LINUX)
+#if defined(OS_LINUX)
// static
void PlatformThread::SetName(const char* name) {
// have to cast away const because ThreadLocalPointer does not support const
@@ -178,6 +174,13 @@ void PlatformThread::SetName(const char* name) {
current_thread_name.Pointer()->Set(const_cast<char*>(name));
tracked_objects::ThreadData::InitializeThreadContext(name);
+ // On linux we can get the thread names to show up in the debugger by setting
+ // the process name for the LWP. We don't want to do this for the main
+ // thread because that would rename the process, causing tools like killall
+ // to stop working.
+ if (PlatformThread::CurrentId() == getpid())
+ return;
+
// http://0pointer.de/blog/projects/name-your-threads.html
// glibc recently added support for pthread_setname_np, but it's not
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698