How can you get the Linux thread Id of a std::thread()

前端 未结 3 736
说谎
说谎 2021-02-07 12:09

I was playing with std::thread and I was wondering how is it possible to get the thread id of a new std::thread(), I am not talking about std::t

3条回答
  •  难免孤独
    2021-02-07 12:13

    How about this:

    pid_t gettid (void)
    {
        return syscall(__NR_gettid);
    }
    

    http://yusufonlinux.blogspot.com/2010/11/get-thread-id-from-linux.html

    Looks like __NR_gettid is defined in unistd.h

提交回复
热议问题