nix::unistd

Function gettid

source
pub fn gettid() -> Pid
Expand description

Get the caller’s thread ID (see gettid(2).

This function is only available on Linux based systems. In a single threaded process, the main thread will have the same ID as the process. In a multithreaded process, each thread will have a unique thread id but the same process ID.

No error handling is required as a thread id should always exist for any process, even if threads are not being used.