File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,20 @@ pub fn setsid() -> Result<pid_t> {
124124 Errno :: result ( unsafe { libc:: setsid ( ) } )
125125}
126126
127+ /// Get the caller's thread ID (see
128+ /// [gettid(2)](http://man7.org/linux/man-pages/man2/gettid.2.html).
129+ ///
130+ /// This function is only available on Linux based systems. In a single
131+ /// threaded process, the main thread will have the same ID as the process. In
132+ /// a multithreaded process, each thread will have a unique thread id but the
133+ /// same process ID.
134+ ///
135+ /// No error handling is required as a thread id should always exist for any
136+ /// process, even if threads are not being used.
127137#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
128138#[ inline]
129139pub fn gettid ( ) -> pid_t {
130- unsafe { libc:: syscall ( libc:: SYS_gettid ) as pid_t } // no error handling, according to man page: "These functions are always successful."
140+ unsafe { libc:: syscall ( libc:: SYS_gettid ) as pid_t }
131141}
132142
133143#[ inline]
You can’t perform that action at this time.
0 commit comments