See the discussion about pthread_atfork(3THR) in The Solution—pthread_atfork(3THR).
Prototype: int pthread_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void) );