Skip to content

Commit

Permalink
Add Thread#internal_name= (#15298)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ysbaddaden authored Dec 23, 2024
1 parent bd4e0d4 commit 7954027
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/crystal/system/thread.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7954027

Please sign in to comment.