> What have I done wrong? I can't find anything wrong, nor can about half a

Here it is:

--- /tmp/threadexamp.c  Tue Apr  2 10:51:17 2002
+++ threadexamp.c       Tue Apr  2 10:51:52 2002
@@ -115,7 +115,7 @@ int addque(struct que *quedata) {
 
 int main() {
                  struct que quedata;
-                 pthread_t *pull_t;
+                 pthread_t pull_t;
                  char *data;
 
                  quedata.head=NULL;
@@ -124,8 +124,8 @@ int main() {
                  // This thread adds items to our que. we detach it because we expect
                  // it to run forever (even though that is not the case at the 
                  // moment).
-                 pthread_create(pull_t, NULL, (void *)addque, &quedata);
-                 pthread_detach(*pull_t);
+                 pthread_create(&pull_t, NULL, (void *)addque, &quedata);
+                 pthread_detach(pull_t);
 
                  while (1) {
                                         // Try and take data off the que

You were passing pthread_create a pointer to an arbitrary memory location,
and it was writing sizeof(pthread_t) bytes to there. The program was
condemned to segfault.

Regards,
Sergey

______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to