Reputation: 2592
In Linux, I need to check if an address belongs to the stack of the thread or not. I have found that pthread_attr_getstack
works for the purpose.
I presume that std::thread is based on pthreads, and so from my std::thread I may find a pthread and use it along with pthread_attr_getstack
in order to check if the pointer points inside the stack. Is that possible? How?
Upvotes: 2
Views: 1579
Reputation: 62563
std::thread::native_handle: Returns the implementation defined underlying thread handle.
See more here: http://en.cppreference.com/w/cpp/thread/thread/native_handle
Having obtained native_handle
(and reasonably believing your implementation is based on pthreads, as it might not be!) you can pass this handle to any pthread
routines your heart desires.
Upvotes: 3