Bug? related to fork and pthreads
Carmelo Amoroso
carmelo73 at gmail.com
Sun May 4 05:58:52 PDT 2008
Dave Hylands wrote:
> Hi,
>
> I've stumbled on what appears to be a problem with pthreads.
> I'm using what I believe is a version of 0.9.29 with the
> linuxthreads.old variant with libpthread as a shared library (it came
> from Wind River - so I'm not 100% sure on the version).
>
> If my program calls fork, then __pthread_reset_main_thread gets
> called, and everything seems to behave correctly.
>
> However, if my program calls daemon (which also calls fork) then
> __pthread_reset_main_thread doesn't get called.
>
> This causes pthread_create's which are called after daemon is called
> to hang, since the wrong thread gets signalled.
> pthread_create trys to signal the original initial thread which
> existed before the daemon call was made.
>
> I've done a kludge by having pthread_create do:
>
> self->p_pid = getpid();
>
> before sending the request which allows my program to work, but I'm
> not sure what the correct fix should be.
>
Hello,
i'm not totally sure, but linuxthreads implementation suffer
of problems when using threads and signal, and your scenario
seems to be fitting perfectly in this context....
this was one of the main reason for which NPTL was developed,
among some others...
so, if I'm right, your problem cannot be solved unless you'll have an nptl
implementation.
Carmelo
More information about the uClibc
mailing list