Solved: If I use pthread_self() instead of getppid() the programs works fine.