2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

util: Set thread name via pthreads in set_subprogram_name().

This makes "top" and "ps" output more readable on FreeBSD at least, and
the names are also visible in debuggers.

Suggested-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
Tested-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
Ben Pfaff
2013-07-25 09:45:43 -07:00
parent dad0f0e793
commit 0f13e65061
2 changed files with 9 additions and 2 deletions

View File

@@ -395,11 +395,17 @@ get_subprogram_name(void)
}
/* Sets 'name' as the name of the currently running thread or process. (This
* appears in log messages.) */
* appears in log messages and may also be visible in system process listings
* and debuggers.) */
void
set_subprogram_name(const char *name)
{
free(subprogram_name_set(xstrdup(name)));
#if HAVE_PTHREAD_SETNAME_NP
pthread_setname_np(pthread_self(), name);
#elif HAVE_PTHREAD_SET_NAME_NP
pthread_set_name_np(pthread_self(), name);
#endif
}
/* Returns a pointer to a string describing the program version. The