Ran out of time but I added a crude check to the branch in 1902326. I noticed at the last moment that Mac has the set function but it is only for the current thread.
On Tue, Jun 28, 2022 at 2:06 PM Ivan Zhakov via dev <dev@apr.apache.org> wrote: > > On Tue, 28 Jun 2022 at 14:45, Yann Ylavic <ylavic....@gmail.com> wrote: > > > > On Tue, Jun 28, 2022 at 1:13 AM <i...@apache.org> wrote: > > > > > > Author: ivan > > > Date: Mon Jun 27 23:13:52 2022 > > > New Revision: 1902297 > > > > > > URL: http://svn.apache.org/viewvc?rev=1902297&view=rev > > > Log: > > > On 'thread-name' branch: Add apr_thread_name_get() and > > > apr_thread_name_set() > > > API to get/set thread name. > > > > > [] > > > --- apr/apr/branches/thread-name/threadproc/unix/thread.c (original) > > > +++ apr/apr/branches/thread-name/threadproc/unix/thread.c Mon Jun 27 > > > 23:13:52 2022 > > [] > > > @@ -277,6 +282,48 @@ APR_DECLARE(apr_thread_t *) apr_thread_c > > > #endif > > > } > > > > > > +APR_DECLARE(apr_status_t) apr_thread_name_set(const char *name, > > > + apr_thread_t *thread, > > > + apr_pool_t *pool) > > > +{ > > > + pthread_t td; > > > + > > > + size_t name_len; > > > + if (!name) { > > > + return APR_BADARG; > > > + } > > > + > > > + if (thread) { > > > + td = *thread->td; > > > + } > > > + else { > > > + td = pthread_self(); > > > + } > > > + > > > + name_len = strlen(name); > > > + if (name_len >= TASK_COMM_LEN) { > > > + name = name + name_len - TASK_COMM_LEN + 1; > > > + } > > > + > > > + return pthread_setname_np(td, name); > > > > We probably need to check for HAVE_PTHREAD_SETNAME_NP since it's _np > > (non-portable). > Thanks for the suggestion! > > I'm not so familiar with autoconf stuff (that's why I created branch): > can I just check for HAVE_PTHREAD_SETNAME_NP or do I need some > autoconf magic to set it? > > > > -- > Ivan Zhakov -- Eric Covener cove...@gmail.com