Page MenuHomeFreeBSD

Add pthread_get_name_np(3).
ClosedPublic

Authored by kib on Aug 13 2018, 3:04 PM.

Details

Summary

The function retrieves the thread name previously set by pthread_set_name_np(3). The name is cached in the process memory.

Requested by: Willem Jan Withagen <wjw@digiware.nl>
Man page update: Yuri Pankov <yuripv@yuripv.net>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 18765

Event Timeline

Just a couple of grammar nits on the manpage.

share/man/man3/pthread_set_name_np.3
52

"function"

72

No "functions" here.

kib marked 2 inline comments as done.

Grammar fixes.

ian added inline comments.
lib/libthr/thread/thr_info.c
86

What about when thread->name is NULL? Doesn't this need handling, like...

else if (len > 0)
  buf[0] = 0;
pluknet added inline comments.
share/man/man3/pthread_set_name_np.3
71

Please note that this duplicates what's already (perhaps, vaguely) documented in pthread(3)'s STANDARDS section:

The functions with the pthread_ prefix and _np suffix are non-portable
extensions to POSIX threads.
kib marked an inline comment as done.Aug 13 2018, 4:19 PM
kib added inline comments.
share/man/man3/pthread_set_name_np.3
71

Yes, but what do you want me to change there ? I do not see a harm in repeating this information.

Handle nameless threads.

This revision is now accepted and ready to land.Aug 13 2018, 4:28 PM
share/man/man3/pthread_set_name_np.3
71

Just a FYI, I see no problem here.

arichardson added inline comments.
lib/libthr/thread/thr_info.c
52

Could this be thread->name = strdup(name) instead? It will also set the value to null on allocation failure.

kib marked an inline comment as done.

Use strdup(3).

I was so concerned with another use of malloc(3) in libthr, so when I decided that it is fine, failed to realize that I reimplemented strdup(3).

This revision now requires review to proceed.Aug 14 2018, 1:56 PM
This revision was not accepted when it landed; it landed in state Needs Review.Aug 17 2018, 6:24 PM
Closed by commit rS337981: Reorder alphabetically. (authored by kib). · Explain Why
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state Needs Review.Aug 17 2018, 6:34 PM
Closed by commit rS337983: Add pthread_get_name_np(3). (authored by kib). · Explain Why
This revision was automatically updated to reflect the committed changes.