We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problematic code:
thread-id/src/lib.rs
Line 57 in b44a6e7
pthread_self() actually returns a handle to the pthread thread object, not the thread id12.
pthread_self()
Downsides:
pthread_t
Suggested solution: syscall(SYS_gettid) or libc::gettid()45.
syscall(SYS_gettid)
libc::gettid()
https://stackoverflow.com/a/27238113 ↩
https://www.man7.org/linux/man-pages/man3/pthread_self.3.html#NOTES ↩ ↩2 ↩3 ↩4
Also, in this case it's libc::pthread_t -> libc::c_ulong -> u64, casting to usize is... ID collision is highly unlikely, but not guaranteed. ↩
libc::pthread_t
libc::c_ulong
u64
usize
https://www.gnu.org/software/libc/manual/html_node/Process-Identification.html ↩
https://www.man7.org/linux/man-pages/man2/gettid.2.html ↩
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problematic code:
thread-id/src/lib.rs
Line 57 in b44a6e7
pthread_self()
actually returns a handle to the pthread thread object, not the thread id12.Downsides:
pthread_t
is not specified in POSIX, assuming is dubious.23Suggested solution:
syscall(SYS_gettid)
orlibc::gettid()
45.Footnotes
https://stackoverflow.com/a/27238113 ↩
https://www.man7.org/linux/man-pages/man3/pthread_self.3.html#NOTES ↩ ↩2 ↩3 ↩4
Also, in this case it's
libc::pthread_t
->libc::c_ulong
->u64
, casting tousize
is... ID collision is highly unlikely, but not guaranteed. ↩https://www.gnu.org/software/libc/manual/html_node/Process-Identification.html ↩
https://www.man7.org/linux/man-pages/man2/gettid.2.html ↩
The text was updated successfully, but these errors were encountered: