Greetings,
I didn't see a searchable archive of this list, so I'll just fire away:
I'm having some issues with pthread_atfork() when call from inside shared
objects. The basic scenario is thus:
Environment: Redhat 7.3 x86, kernel 2.4.18, glibc 2.2.5.
A library (call it 'testlib') has been written that will be called from both
multi-threaded and multi-process applications. The architecture of these
applications is not under my control. Each thread needs it's own copy of
various data structures and to perform thread-specific initialization tasks.
In essence, the library needs to "know" when a call comes down that is the
first call of a new thread (forked or otherwise) and perform setup.
As an example, let's boil this down to a basic case one process with one
thread forking one child. Let's call the most frequently-accessed routine
getTSD(). The outline of getTSD() is:
- use pthread_once to setup a global TSD key (pthread_key_t) that will
refer to an int*. All threads will use that key to index into their
local copy of the int*.
- get the TSD, if it's NULL, do the various initialization tasks for
the thread (such as allocated the memory the int* will point to),
otherwise, just return the TSD int*.
I have a sample library and test application that does this available at:
http://www.redgeek.net/~barclay/pthread-test.tgz
The interesting part is that my application works if compiled as a static
archive, but the atfork handlers don't seem to trigger if the library is
compiled as a shared object. Debugging inside gdb w/ multiprocess/multithread
seems a lost cause ('set follow-fork-mode child' doesn't work, at least on
x86.)
Any help is appreciated, feel free to wget pthread-test.tgz, the code can
probably describe my setup better than text. Standard usage: untar, cd,
make. It'll build both a .a and .so version of the library, and two
executables, test-ar and test-so, each of which link with the previous,
respectively.
Thanks for your time,
-Barclay
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
Development Site http://www.ossp.org/pkg/lib/pth/
Distribution Files ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]