Skip to content

Instantly share code, notes, and snippets.

@kostja

kostja/output

Created Feb 8, 2015
Embed
What would you like to do?
pthread_self() returns the same value across after fork()
kostja@atlas ~ % gcc -pthread foo.c; ./a.out
thread id: 140508398954304
thread id: 140508398954304
thread id: 140508398954304
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
int main()
{
printf("thread id: %llu\n", (unsigned long long) pthread_self());
fork();
printf("thread id: %llu\n", (unsigned long long) pthread_self());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.