Skip to content

Instantly share code, notes, and snippets.

@koush
Created September 21, 2010 21:30
Show Gist options
  • Save koush/590606 to your computer and use it in GitHub Desktop.
Save koush/590606 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
typedef struct pthread_internal_t
{
struct pthread_internal_t* next;
struct pthread_internal_t** pref;
pthread_attr_t attr;
pid_t kernel_id;
pthread_cond_t join_cond;
int join_count;
void* return_value;
int intern;
__pthread_cleanup_t* cleanup_stack;
void** tls; /* thread-local storage area */
} pthread_internal_t;
int main(int argc, char** argv) {
int pid = fork();
int self = pthread_self();
pthread_internal_t* t = (pthread_internal_t*)self;
printf("%d %d %d\n", pid, t->kernel_id, gettid());
// 7196 7195 7195
// 0 7195 7196
// Note that the internal kernel ids are the SAME after fork. This is wrong!
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment