From 9e541c8b9818a60ec03c64a25b614006aba1f6d1 Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Fri, 6 Dec 2024 18:46:10 +0100 Subject: [PATCH] Add Thread#internal_name= Allows to change the Thread#name property without affecting the system name used by the OS, which affect ps, top, gdb, ... We usually want to change the system name, except for the main thread. If we name the thread "DEFAULT" then ps will report our process as "DEFAULT" instead of "myapp" (oops). --- src/crystal/system/thread.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crystal/system/thread.cr b/src/crystal/system/thread.cr index 0d6f5077633a..fec4a989f10a 100644 --- a/src/crystal/system/thread.cr +++ b/src/crystal/system/thread.cr @@ -182,6 +182,11 @@ class Thread self.system_name = name end + # Changes the Thread#name property but doesn't update the system name. Useful + # on the main thread where we'd change the process name (e.g. top, ps, ...). + def internal_name=(@name : String) + end + # Holds the GC thread handler property gc_thread_handler : Void* = Pointer(Void).null