Linux 线程 ID 和 设置名字

头文件要有:

#include <unistd.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <sys/prctl.h>

程序:

    printf(" tid : %d \n", syscall(224));
    prctl(PR_SET_NAME, "test_Thread");

运行后

 ps 结果:

当 不是多线,则 pid = tid ;

猜你喜欢

转载自blog.csdn.net/xiuscut/article/details/83148070