From 7954027587f3b47dbb1aae64417aa9746a6e0ca7 Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Mon, 23 Dec 2024 12:25:02 +0100 Subject: [PATCH] Add Thread#internal_name= (#15298) 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