I tried to write a semaphore test and it always segfaulted while printing an error.
Attaching a simple error printing program that segfaults (after pthread_create) for me. -- Michal Suchanek [EMAIL PROTECTED]
#define _GNU_SOURCE #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <error.h> #include <errno.h> #include <stdio.h> #include <string.h> #define THREADS 500 void * foo (void *arg) { error (0, EGREGIOUS, "Message foo"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); return NULL; } int main (int argc, char **argv) { error_t err; pthread_t tid; void * ret; fprintf (stderr, "This should print a bunch of error messages.\n\n"); error (0, EGREGIOUS, "Message start"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); error (0, EGREGIOUS, "Message init"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); err = pthread_create (&tid, NULL, foo, NULL); if (err) error (0, errno, "pthread_create"); error (0, EGREGIOUS, "Message create"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); sched_yield(); error (0, EGREGIOUS, "Message yield"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); err = pthread_join (tid, &ret); if (err) error (0, errno, "pthread_join"); error (0, EGREGIOUS, "Message join"); error (0, EGREGIOUS, "Int1 %i Int2 %i", 1, 2); if ((int)ret) error (0, EGREGIOUS, "Main: Thread return value %i should be 0", (int)ret); return 0; }