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:

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

This number can be found like this:

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