in reply to Detecting fork events in a module?
In pthreads there is a thing called a "fork handler", see man pages for pthread_atfork.
Basically it calls user written functions on a fork - "fork handlers" (and an opportunity for a Two Ronnies joke). Three handlers may be written, to be executed in the parent before the fork, in the parent after the fork, and the child after the fork (all are optional).
The feature is meant for mutex handling, but I guess you could use it for this. The problem is that you would have to write it in XS.