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 everyone, Cygwin seems to behave strangely when `printf` is used in threads: if the first `printf` encountered occurs in another thread, then the first `printf` that occurs in the main function will vanish into thin air. The following fragment illustrates this: #include <stdio.h> #include <stdlib.h> #include <pthread.h> void *func(void *arg) { printf("thread_printf\n"); return NULL; } int main(int argc, char **argv) { pthread_t thread; pthread_create(&thread, NULL, func, NULL); pthread_join(thread, NULL); printf("main_printf1\n"); /* This line never gets printed */ printf("main_printf2\n"); return 0; } When compiled with `gcc` with no options, the output is: thread_printf main_printf2 I'm not familiar with the Cygwin codebase. If someone can point me in the right direction, I might be able to figure out what is causing this issue. I appreciate the if someone can help me figure this out, though I understand it's not exactly a critical issue. Thanks all.
Attachment:
cygcheck.out
Description: Binary data
#include <stdio.h> #include <stdlib.h> #include <pthread.h> void *func(void *arg) { printf("thread_printf\n"); return NULL; } int main(int argc, char **argv) { pthread_t thread; pthread_create(&thread, NULL, func, NULL); pthread_join(thread, NULL); printf("main_printf1\n"); /* This line never gets printed */ printf("main_printf2\n"); return 0; }
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |