Post

Cool trick to get current TID (since gettid is not implemented on debian it seems)

The gettid() call doesn't work on my system so I found this:

1
printf("The ID of this of this thread is: %ld\n", (long int)syscall(224));

This number can be found like this:

1
2
benjamin@benjamin-laptop:~$ grep gettid /usr/include/asm/unistd_32.h 
#define __NR_gettid     224

Ripped from this thread: http://ubuntuforums.org/showthread.php?t=345317

This post is licensed under CC BY 4.0 by the author.