Add fork hooks for pthread_atfork

pthread_atfork needs application callbacks to be called outside any locking.