外观
头文件
#include <sys/syscall.h>
#include <stdio.h> #include <unistd.h> #include <sys/syscall.h> int main(int argc, char const *argv[]) { pid_t tid = syscall(SYS_gettid); printf("tid: %d\n", tid); return 0; }
输出
gcc -g thread.c -o thread && ./thread tid: 139