Re: I'v got nuts, please help me with the g++ option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try replacing the 
>pthread_t * thread;

with 
pthread_t thread;

and creating thread with:
pthread_create (&thread,NULL,threadproc,NULL);
pthread_join (&thread, NULL);

You need to look into memory allocation for the variable thread!!
Suggestion to read Richard Stevens' book on IPC.

Sar

--- Jianhua xu <joshua_60030@xxxxxxxxx> wrote:
>Dear Mr./Madam,
>   I installed a Redhat9(shrike), g++ 3.2.2 , libgcc
>3.2.2, got Segmentation fault when using
>pthread_create function. the try program is very
>simply, please tell me which header file and library i
>should use when linking.
>
>following is my program
>
>#include <>
>#include <pthread.h>
>void * threadproc(void*p)
>{
>printf("dd\n");
>}
>int main(int argc,char** argv)
>{
>pthread_t * thread;
>pthread_create(thread,NULL,threadproc,NULL);
>pthread_join(*thread,NULL);
>return 1;
>}
>
>
>Thanks & Regards,
>
>joshua
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com

_____________________________________________________________
Powered by a short email address ... http://www.k.st


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux