This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello all, I have a problem. I have a bug or misconfig that manifests itself in pthreads.h. Basically, if a child thread ends, the main thread stops executing. The program does not end, but it doesn't go any further. I see that a similar problem was posted to this list about 2 weeks ago, but this is slightly different, and my example program is not a lab, and does nothing but show the problem. I don't see a solution posted to that thread. Hopefully, someone can verify this as a bug or show me my misconfiguration. Or, of course, briefly explain to me how I'm misusing pthread_* functions, if that's the case. Output from cygcheck -s -v -r is attached. Here is the program executed on a debian sarge box: ben@hydra:~$ gcc -lpthread threadprob.c threadprob.c: In function `main': threadprob.c:15: warning: passing arg 3 of `pthread_create' from incompatible po inter type threadprob.c:13: warning: return type of `main' is not `int' ben@hydra:~$ ./a.out looping in main looping in thread func at 1 looping in main looping in thread func at 2 looping in main looping in thread func at 3 looping in main looping in thread func at 4 looping in main looping in main looping in main looping in main looping in main looping in main <ctrl-c> Here is the program running in my cygwin environment: Administrator@benlaptop ~/ptp $ gcc -lpthread threadprob.c threadprob.c: In function `main': threadprob.c:15: warning: passing arg 3 of `pthread_create' from incompatible po inter type threadprob.c:13: warning: return type of `main' is not `int' Administrator@benlaptop ~/ptp $ ./a.exe looping in main looping in thread func at 1 looping in main looping in thread func at 2 looping in main looping in thread func at 3 looping in main looping in thread func at 4 looping in main <ctrl-c after 30 seconds> Here's the source for threadprob.c: #include <pthread.h> void thread_func() { int x = 0; while (x++ <= 3) { printf("looping in thread func at %d\n",x); sleep(1); } pthread_exit(0); } void main() { pthread_t tid; pthread_create(&tid,NULL,thread_func,NULL); while (1) { printf("looping in main\n"); sleep(1); } printf("shouldn't happen\n"); exit(1); } Thanks for your time, ben
Attachment:
cygcheck.out
Description: Binary data
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |