You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Auto merge of rust-lang#3953 - YohDeadfall:glibc-thread-name, r=RalfJung
Fixed pthread_getname_np impl for glibc
The behavior of `glibc` differs a bit different for `pthread_getname_np` from other implementations. It requires the buffer to be at least 16 bytes wide without exception.
[Docs](https://www.man7.org/linux/man-pages/man3/pthread_setname_np.3.html):
```
The pthread_getname_np() function can be used to retrieve the
name of the thread. The thread argument specifies the thread
whose name is to be retrieved. The buffer name is used to return
the thread name; size specifies the number of bytes available in
name. The buffer specified by name should be at least 16
characters in length. The returned thread name in the output
buffer will be null terminated.
```
[Source](https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getname.c;hb=dff8da6b3e89b986bb7f6b1ec18cf65d5972e307#l37):
```c
int
__pthread_getname_np (pthread_t th, char *buf, size_t len)
{
const struct pthread *pd = (const struct pthread *) th;
/* Unfortunately the kernel headers do not export the TASK_COMM_LEN
macro. So we have to define it here. */
#define TASK_COMM_LEN 16
if (len < TASK_COMM_LEN)
return ERANGE;
```
0 commit comments