Changed to use the gettid system call.