File: s-taskname.c

package info (click to toggle)
uftrace 0.9.0-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 3,896 kB
  • sloc: ansic: 41,425; python: 7,369; makefile: 698; asm: 488; cpp: 461; sh: 349
file content (20 lines) | stat: -rw-r--r-- 310 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define _GNU_SOURCE
#include <sys/prctl.h>
#include <pthread.h>

void task_name1(const char *name)
{
	prctl(PR_SET_NAME, name, 0, 0, 0);
}

void task_name2(const char *name)
{
	pthread_setname_np(pthread_self(), name);
}

int main(int argc, char *argv[])
{
	task_name1("foo");
	task_name2("bar");
	return 0;
}