0

I would like to know if there exists a portable way to retrieve the current stack pointer value in C of a specific POSIX thread, pointed by its thread ID? The only way to get an approximate stack pointer value is to kill an interrupt to a specific the thread (using pthread_kill) and having a signal handler of the signal being fired have a function similar to the following function:

void handleCustomSig(int sig) {
    int temp; // Or any preferred type, as I
              // don't think this would matter
              // here.
    void* currentStackPtr = &temp; // Save this somewhere. 
}

Would there be a much cleaner way to get the current stack pointer of a specific thread?

Also, a side question, are there any specific range of unused signals that maybe available for custom use?

falhumai96
  • 327
  • 2
  • 17

0 Answers0