On 20020207 Felipe Contreras wrote:
>Hi,
>
>I've found a weird problem in linuxthreads. When I get out of a thread it
>happends one of three, the new thread get's defuct and the proccess never
>ends, it segfaults, or it works.
>
>The most weird is that it depends on the kernel, and also when I run the
>test trought gdb there is no problem.
>
>Here is the test:
>
>#include <pthread.h>
>
>void *test(void *arg) {
> puts("Thread2");
> return 0;
>}
>
>int main() {
> pthread_t tt;
> puts("Before Thread2");
> pthread_create(&tt,NULL,test,NULL);
> puts("After Thread2");
> return 0;
>}
>
Buggy program that could give unspecified behaviour, unless pthread
standard talks about orphaned threads...
Your main program can die (exit) before child thread ends, so it has
nobody to notify its dying or return to.
Try with a sleep(1) before main return, or better, do a
pthread_join().
-- J.A. Magallon # Let the source be with you... mailto:jamagallon@able.es Mandrake Linux release 8.2 (Cooker) for i586 Linux werewolf 2.4.18-pre9-slb #3 SMP Fri Feb 8 01:33:12 CET 2002 i686 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Feb 15 2002 - 21:00:18 EST