Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 593030
Collapse All | Expand All

(-)file_not_specified_in_diff (-2 / +27 lines)
Line  Link Here
0
-- a/include/pthread.h
0
++ b/include/pthread.h
Lines 214-219 struct cpu_set_t; Link Here
214
int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
214
int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
215
int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
215
int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
216
int pthread_getattr_np(pthread_t, pthread_attr_t *);
216
int pthread_getattr_np(pthread_t, pthread_attr_t *);
217
int pthread_setname_np(pthread_t, const char *);
217
int pthread_tryjoin_np(pthread_t, void **);
218
int pthread_tryjoin_np(pthread_t, void **);
218
int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
219
int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
219
#endif
220
#endif
220
-- /dev/null
221
++ b/src/thread/pthread_setname_np.c
Line 0 Link Here
1
#include <fcntl.h>
2
#include <string.h>
3
#include <unistd.h>
4
5
#include "pthread_impl.h"
6
7
int pthread_setname_np(pthread_t thread, const char *name)
8
{
9
	int fd, status = 0;
10
	char f[sizeof "/proc/self/task//comm" + 7];
11
	ssize_t len;
12
13
	if ((len = strlen(name)) > 15) {
14
		errno = ERANGE;
15
		return 1;
16
	}
17
18
	snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
19
	if ((fd = open(f, O_WRONLY)) == -1) return 1;
20
	if (write(fd, name, len) == -1) status = 1;
21
22
	close(fd);
23
	return status;
24
}

Return to bug 593030