On Tue, Jun 28, 2022 at 7:45 AM 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).
FWIW: AFAICT missing on AIX but present on z/OS and "IBM I". Kind of a surprising result.