Skip to content

Commit

Permalink
Ensure Process.ProcessName doesn't change when setting Thread.Name on…
Browse files Browse the repository at this point in the history
… Linux

Fixes dotnet/runtime#33673

This issue is a side-effect of adding support for setting thread names on Linux in dotnet/coreclr#27182.

cc @janvorli @lpereira @SteveL-MSFT
  • Loading branch information
tmds committed May 6, 2020
1 parent c2795c9 commit 7fe6060
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mono/utils/mono-threads-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
if (tid != mono_native_thread_id_get ())
return;

#if defined(__linux__)
/*
* Ignore requests to set the main thread name because
* it causes the value returned by Process.ProcessName to change.
*/
if (mono_native_thread_os_id_get () == (guint64)getpid ())
return;
#endif

if (!name) {
pthread_setname_np ("");
} else {
Expand Down

0 comments on commit 7fe6060

Please sign in to comment.