From a40012115277aeff07ff92abab652b996be3c9cf Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Thu, 11 Jul 2024 23:36:39 +0100 Subject: Add thread_get_name RPC to get the name of a thread. Message-ID: <6qm4fdtthi5nrmmleum7z2xemxz77adohed454eaeuzlmvfx4d@l3pyff4tqwry> --- kern/thread.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'kern/thread.c') diff --git a/kern/thread.c b/kern/thread.c index 68cc667e..a656c076 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2647,3 +2647,24 @@ thread_set_name( thread->name[sizeof thread->name - 1] = '\0'; return KERN_SUCCESS; } + +/* + * thread_get_name + * + * Return the name of the thread THREAD. + * Will use the name of the thread as set by thread_set_name. + * If thread_set_name was not used, this will return the name of the task + * copied when the thread was created. + */ +kern_return_t +thread_get_name( + thread_t thread, + kernel_debug_name_t name) +{ + if (thread == THREAD_NULL) + return KERN_INVALID_ARGUMENT; + + strncpy(name, thread->name, sizeof thread->name); + + return KERN_SUCCESS; +} -- cgit v1.2.3